Reasonably efficient y-sorting in Unity with 2D Toolkit

It’s been quite some time since I’ve posted anything – we’ve been busy launching Letter Quest Remastered on Steam, launching a game at my day-job, and all kinds of other things. I’ve finally found a bit of time to start getting back into some coding, so it’s about time I start posting on here again! 🙂 I’ve been learning how to use 2D Toolkit more effectively in Unity – Letter Quest Remastered uses 2D Toolkit for most of the in-game art, with all of the animations being handled by the awesome Spine animation tool. The new game idea that I’m thinking about tackling next requires sorting all characters and enemies on the screen by y-value, so that things that are closer to the bottom of the screen will appear over top of things that are further up (back). Without doing any y-sorting, you get results like this: You can see that there’s no sorting going on, slimes are overlapped at random (actually based on the order that they were created). With a bit of y-sorting, we get a much nicer result: Unity makes it very easy to do this sort, it’s actually just one line of code in an Update function in each class, and takes advantage of a renderer’s sorting order: void Update() { mRenderer.sortingOrder = (int)(mScreenHeight - this.transform.position.y); } I can get away with simply using the transform’s y-position, because with the way I have everything set up, that actually corresponds to the bottom of my enemies. You might have to do a bit of offsetting based on the height of your enemies – you generally want a sort like this to be based on the bottom of objects. To make this more efficient, you could set the sortingOrder of all objects from a single Update function in a manager class, and you could probably get away with calling it 10 to 20 times a second, instead of every frame. I don’t need the performance (yet!), and I also have other logic in Update for each enemy, so it makes sense to do this in each enemy’s Update...

read more

Letter Quest PC and Mac Changes

As most of you are already aware, Letter Quest started off as a mobile game. We have had plans on making it a desktop game since the beginning, but started with the mobile version since we could complete it more quickly. Many people have been asking what changes we made for the desktop version, so we decided to share the full list of changes…be warned, this is a huge list!! Added proper resolution support Added incredibly high resolution textures (that look fantastic even on a 4K monitor!) Added 3 save slots so that multiple people can play on one copy of the game Added an entirely new “expert mode” that changes a bunch of things in the game, and is incredibly difficult, which a lot of players asked for Added 7 (technically 8, but that’s a secret, shhh!) story comics to help explain Grimm’s journey Added key bindings (this isn’t really feature-worthy, but is worth mentioning since a lot of so-called “mobile ports” don’t even bother, which we think is ridiculous!) Rebalanced the entire game to be feel a lot better since there are no in-app purchases or gem doubler available Tweaked the difficulty of most stages, monsters, and challenges Reworked the entire game UI, including a lot of custom UI (in battle the entire UI is changed, with a lot more details visible like your best words, previous word, monster details, etc.), and we actually had to go through and resize every bit of UI by certain amounts because unlike some cheaply-done mobile ports, we realized that simply scaling a mobile game up to desktop resolutions would make all of the UI huge and awful…so a good 95% of the UI was scaled down by various amounts for the desktop version Created a whole new map that has distinct areas Created 4 additional sets of background art, one per area (the mobile version only had the one set of bg art for the whole game, the haunted house) Added 4 additional music tracks, one per area (the mobile version only had one song for all stages) Included the entire soundtrack with every purchase, along with custom front and back cover art, and custom disc art that is printable in case you want to make up your own Letter Quest music CD Added 4 high resolution 2560×1440 desktop backgrounds, and 9 custom avatar images for use on forums, websites, profiles, etc. Added the definitions of over 160,000 of the 190,000+ words in the game’s dictionary, and allow the player to view the definition of any word that is currently spelled out, as well as automatically showing the definition after each word is submitted Added mouse-over highlights to every button and clickable object in the game, except for the letter tiles in battle, since that is really nice to have on PC Added the ability to disable the anonymous statistics that the game gathers, since a few players mentioned that they don’t like having that in a game (although we can tell you that they are completely anonymous, and the biggest use we have for them is actually to log when crashes happen so that we are able to fix bugs, as well as telling us which operating system and resolutions are being used, again so that if there are any problems we know where to look/how to test) – ideally we’d have a testing team, but our whole company is only two people, only one of which is full-time, so testing happens with family members, kind folks on the internet, and by us in our non-existent spare time A...

read more

Opening Steam to a Greenlight Page (Easier Voting!)

We’ve had Letter Quest on Steam Greenlight since April 11, 2014. Once you get taken off the front page of Greenlight, you’re on your own for trying to get people to go there and vote…it’s really difficult! The Newgrounds demo that we recently posted has helped out a lot – we’ve gone from getting around 10 “yes” votes a day on Greenlight, to around 40! That’s a huge jump, since the only thing that changed was the Newgrounds demo. One thing that is very difficult is actually getting people to vote – it’s tricky because most people don’t ever log into Steam in their web browser, instead they are actually logged in to Steam. This tip is absolutely not my own – it’s from a wonderful Gamasutra article. You can see the tip at the bottom of the article, where it says “Update:”. The original person that created this solution is the developer of Black Annex, and you can see his post here. Here’s the summary: if you want more votes on Steam, you need to make it easier to vote. The easiest way for most people is to vote in the Steam app. So you create a special link that opens Steam directly to a Greenlight page, here’s how: You first create a tiny php file containing the following code: <?php header('Location: steam://url/CommunityFilePage/248089760'); ?> Where “248089760” is the ID of your Greenlight page. Then you simply point people to your php file in a browser, and it will open Steam to your Greenlight page! One thing you can do to make this cleaner is to create a URL that redirects to your php file, we used http://greenlight.letterquestgame.com (try clicking it if you have Steam running on your computer!), which looks a lot more friendly. Also, it’s nice because our main page for Letter Quest is at http://www.letterquestgame.com, so most people tend to trust that greenlight link more because it’s on a recognized domain name. Good luck on Greenlight everyone! We’re currently 45% of the way to the top 100 – it’s a lot of work but we’re hoping we’ll eventually get...

read more

Exporting Your Best Word as an Image

For quite a while now, we’ve had the ability to export a picture after a battle in Letter Quest on mobile, and post it to twitter. Each image features the best word that was spelled, the damage it did, the character you played as with the weapon and letter tiles you were using, and the stage background and monster you were fighting. People really seemed to enjoy this feature, and we were happy with it. Now that Letter Quest is also on desktop, we wanted a way for players to export their best word as an image, even though we’re not using twitter on desktop (if someone has a nice solution for integrating twitter into a desktop game, we’d love to hear it!). So we simply added a button at the end of each battle, and it lets you save an image of your best word. You can then post it anywhere you like – facebook, twitter, your own site/article, anywhere! Here’s what it looks like after a battle: And here’s a couple examples of some exported images: This functionality will be in the final release of Letter Quest, which is currently available in early access – and every early access copy will be upgraded to the final version for free when it’s available....

read more

Flash Content and allowFullscreen

We recently put a Letter Quest demo on Newgrounds. It’s doing very well, with great ratings and lots of plays (7000 in just under two days!). But one important thing you need to realize when you post a game on Newgrounds… Your game will get posted on other sites. A lot of them. And the more popular that your game is, the more sites you’ll see it pop up on suddenly (at the time of this writing the Letter Quest demo is on over 15 sites that we didn’t post it to). Now, it’s not a bad thing when your game gets spread around the internet, especially when it’s a free demo. What is bad is when you have a button in your game that allows the player to switch between fullscreen and windowed, and the site hosting your game decides to set allowFullscreen to false in their index.html. It’s even worse when you fail to account for that in your code, and the game throws an error whenever someone clicks that nice (now evil, nefarious, nasty) fullscreen button. Luckily there’s a pretty simple fix – a huge thank you to Sarah Northway for her reply on stackoverflow about how to detect if that flag is set. Basically you can detect if it’s set using if (stage.hasOwnProperty("displayState") && stage.hasOwnProperty("allowsFullScreen") && stage["allowsFullScreen"]) { // fullscreen allowed } else { // fullscreen not allowed } So I simply added that check, and if fullscreen is not allowed, I don’t bother showing the fullscreen/windowed toggle button. Problem solved. Well, mostly… IMPORTANT: As Sarah notes, the property that this code checks was added in Flash Player 10.2, so in older versions of Flash Player, it won’t give you a reliable result (but it won’t crash). So I also added some extra code to handle the case where the button is still visible, and fullscreen is not allowed, and in that case I catch the error and then set a global flag saying that fullscreen is not allowed. The only catch here is that most Flash gaming sites that borrow (steal?) your game’s swf will actually make a copy of it. So upgrading the swf on Newgrounds was only part of the battle. I also contacted the owners of each site that is hosting the game, and asked them to manually update to the new swf. Surprisingly, every single one of them got back to me within a day and updated their swf for the game – I was really impressed, thanks for being awesome everyone!...

read more

Apple’s new Advertising Identifier Usage and App Updating

We recently released a huge update for Letter Quest, and when we went to submit it to Apple, we were presented with some new popup asking all kinds of questions about an advertising ID, whether or not we were using it, and how we were using it. I read up on it and figured out how to answer everything, and submitted the update like usual. A week later, the update was rejected. The reason given was that we were using the advertiser ID in our app, but didn’t have any ads. Strange, I could swear that we added AdMob banner ads and Vungle video ads in the most recent update. A quick test in the app and yes, both of those ad types are actually in there (until you buy something in the game, then they’re removed). So what gives? Turns out that Apple reviewers probably don’t spend a lot of time testing each app update they receive, which makes sense given the volume they must deal with. However, the ads in Letter Quest are quite easy to find. So I assumed that our app actually was okay, and should be approved, so I entered an appeal to the rejection. Basically I explained in painstaking detail how to find the banner and Vungle ads, how to trigger them, when they show up and under what conditions, etc. Two days later and the update was approved with no changes on our part. So what should you take away from this? If you use ads in your app (iAd doesn’t count for this purpose), then make sure to include very detailed instructions about how to view/access them, how/when they show up, and what type of ads you have in your app in the review notes when you submit your app or app update. All told this silliness caused us to have an app that finally became available on a Monday afternoon instead of Friday evening, which is brutal, considering we tend to see our highest revenue on weekends. Disappointing, but at least it should never happen again – I’ll be giving tons of info with every app review in the notes from now...

read more