Errors when creating Large TileMaps with Cocos2D

Image

Lately I’ve been building a lot of tilemap based games in Cocos2D and I’ve got to say, it’s pretty freaking sweet. There’s a lot of great tutorials on how to get started, plenty of help in the Cocos2D forums, and even a few videos people have put together. I did run into an issue today that I felt others may run into, so I wanted to post the solution.

I have a few levels in my game which require more than one TileMap. I ended up using two tile maps in 1 layer and I got the following compiler error:

 

*** Assertion failure in -[CCTMXLayer setupTiles]

This error is actually masking an error, and it took about 10 minutes for me to track down the actual problem. You can not use more than 1 TileMap per Layer. If you’re using TileD you just need to create a new layer and use your 2nd TileMap on it. All will be well. If you’re not using TileD then you are missing out because it’s a seriously awesome tool.

 

Wii U and the default Warawara Plaza bug

Image

While this technically has nothing to do with game development, I thought I’d go ahead and post this since the internet is void of many answers. The short story is this: My Wii U Warawara plaza was only displaying the default Nintendo Miis as if I wasn’t connected to the internet.

The thing is, it used to work. It used to work just fine. Then one day it stopped. Well, that’s not technically true, I know exactly what I did. When I first set up my Wii U I put my Wife’s Mii as the default user. (It was a gift to her, so that seemed appropriate).  After a few weeks she asked that the default Mii be changed to mine. (I don’t think she liked people using the ‘Yeah!’ function on her drawings and such). So that’s what I did, I changed the default user to my Mii and then Warawara plaza went back to the default plaza… and never changed back.

I searched for weeks trying to figure out how to fix it, but nothing I did worked. I made sure I had set up my Friends list, I could navigate the Miiverse just fine. People I ‘Followed’ in the Miiverse would show up in WaraWara Plaza, but it still didn’t look or act right.

Finally it started working again. I’m not sure ‘exactly’ how, but here’s what I did and why I think it worked. We have several games, each of which we’ve played at least once on the Wii U when the user was my Wife’s Mii. I know that there is cached data saved in the system about each game, and I know there is cached data for every game for every User Profile. After changing to my Mii I didn’t play every game again. I played all except 1: Zombie U. (I’d been wrapped up with Arkham City and Mario Bros). When I finally put the Zombie U disc in yesterday everything in WaraWara started working again. I think that every game needed to have some initialization data saved in the User Profile in order to access the System information.  Since I was missing the Zombie U files, Warawara must have hit a false condition and just hung with the default plaza.

This is all observational, nothing scientific about my theory, but seeing as dozens of other Wii U owners have this issue I thought I’d put this up as a possible solution.

Cocos2d retina support

Cocos2d is probably the most used and least documented framework out there. I’m used to docs being out-dated (doc is the most important and least maintained part of a framework) but Cocos2d gets to be my biggest loser on this scale. All that criticism aside, once you finally figure out how things are supposed to work it’s actually really nice.

If you’re familiar with the xCode you’re probably familiar with Apple using the @2x suffix on the end of their files when they need something larger than the original iPhone display resolution.  To date this is what Apple’s doing:

default.png – iPhone 3GS and older resolution
default.png@2x -Retina 3.5 inch
default-568h@2x.png – Retina 4 inch (iPhone 5 nonsense… seriously Apple?)

Cocos2d takes a similar approach:

default.png – iPhone 3GS
default-ipad.png – iPad 1 and 2 resolution
default-ipadhd.png – Retina resolutions (I don’t think they’ve got a Retina 4 inch file type as of yet.. but then again, how could I possibly know?)

This short story is you should only specify default.png as the file you’re trying to load as a Sprite. Cocos2d will automatically look to see if you have that file with the -ipad or -ipadhd extension, and load that if appropriate. (That’s all determined if you’ve got retina display enabled. Here’s some pseudo code for that:


if( ! [director_ enableRetinaDisplay:YES] )
CCLOG(@"Retina Display Not Supported");

Hope that helps!

The Atlanta Game Dev Podcast


When I first started this blog a few years back I was a flash developer who decided to try out this Unity thing. Since then I’ve started my own game studio, had some awesomely successful games launched (some self published, some contracted out by other companies), and tried my best to post answers to incredibly annoying problems I come across.

For those of you who visit this blog often, I thought you might be interested in my podcast: The Atlanta Game Developer Podcast. I sit down with Cartoon Network’s Brad Merritt (His blog is the bullet pattern blog that you should totally read) and we crack wise and talk about all things Game Dev.

I don’t usually self promote things like that, but hey – maybe you guys will dig it.

Upgrading Unity Android, or How I learned to embrace masochism…

I’ve been working on a game for about a year called The Secret Castle. It’s coming along great and we’re getting really close to release. We’re launching for both Android and iOS, and I’ve been doing the bulk of the work on my PC (I can’t seem to live without multiple monitors).

I ran got burned during the great upgrade of 3.3 and swore that I wouldn’t ever upgrade my main development box again without testing it out in a VM or something first. I’ve been working on 3.4.2 for a while with no problems, and I had been ignoring the upgrade nags about 3.5.2 until I finally had some time to test the upgrade in a VM.

So, I fire up Virtual Box, upgrade my project – everything works fine. Test successfully complete. OK – on to the real thing!

I upgrade my development machine, everything also works fine. No errors, no warnings, it’s all looking good. I then connect up my tablet and try to build to it:


 Failed to re-package resources with the following parameters:
 package -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "C:/Program Files (x86)/Android/android-sdk-windows/platforms/android-Honeycomb\android.jar" -F bin/resources.ap_
 Configurations:
 (default)
 hdpi Continue reading 'Upgrading Unity Android, or How I learned to embrace masochism…'

Remembering why I hate AS3

I’ve mostly switched over to Unity development, but once in a while a client will request a game in Flash and I take the job. It’s been about a year since I’ve done any AS3 work, but I picked it back up pretty quickly.

I started building my baseclass with all my reusable methods and started with the once I use the most (Pause, fadeIn, fadeOut, etc).  I started knocking everything together and it was going just fine, but then after adding in several classes I noticed that my alpha transitions started to hang randomly… how curious!  Here’s an example of my base class: Continue reading ‘Remembering why I hate AS3’

iPad 3 and the Retina Display – It will make you a liar…

Recently I was hired by some folks to build them a game for their iOS news stand app. I’ve done this a few times before so I figured that this would be an easy, no headache job. The game was to be developed in HTML5 and Javascript, also not a problem and I’ve done it several times before. Here’s the twist – the client wanted to take advantage of the new iPad 3 Retina display. I hadn’t yet purchased an iPad3, but I quickly looked over the specs: Retina display resolution is 2048 x 1536. Shouldn’t be a problem! Continue reading ‘iPad 3 and the Retina Display – It will make you a liar…’

Writing Unity Custom Editors in C#

As your games become more complex you’re probably going to start to get frustrated with how complex the Unity Inspector can be. Editing 4 different arrays all containing linked information about an object and keeping it all in sync can start to add up, especially if you’re building these tools for game designers to come behind you and use or tweak. Writing custom editors for the inspector is an incredibly useful tool for keeping it clean and manageable on the surface while being complex under the covers.

Ok, enough trying to sell you on using customer editors. I recently decided to write a custom editor in c# and found that the documentation only gives you code for JavaScript. After grinding it out for a bit I finally figured out how to do it in C#: Continue reading ‘Writing Unity Custom Editors in C#’

Unity Android and OpenGL ES 2.0 – another cautionary tale…

In my previous post I mentioned how excited I was to finally get over a huge crashing issue I had with Zombie Room AR. While that post is still completely accurate, my total celebration was a little premature. A couple of days after pushing out the latest fixes I got another email from a user experiencing a crash… Seriously!? I just.. but I… come on…

So here I sat with ANOTHER crash happening – this one was crashing in the exact same way, and once again it wasn’t putting together a report of a stack trace for me to find the underlying problem. Whiskey sure is tasty! Continue reading ‘Unity Android and OpenGL ES 2.0 – another cautionary tale…’

Unity Android and the Android Market Licensing (LVL) – a cautionary tale…

If you’ve been following this blog then you no doubt know all about my augmented reality game Zombie Room AR. What you may not know is how much of a struggle I’ve had trying to support it. If you look at the demo version in the android market you’ll see a crap  load of 1 star reviews saying the game crashes and that I suck and other idiotic comments. Over the past year I’ve been an Android developer and I know that the Star ratings and comments are on par with youtube comments, so I’ve brushed most of these off…

Unfortunately, the one thing these comments have in common is that they’re right… the game just crashes on a lot of devices… mysterious crashes that leave me scratching my head in wonder. The strangest thing is that when the game crashes, it just sort of exits. Typically when a program crashes on Android you get a box pop up with a “Force Close” or “Report” option. If you click “Report” it sends a stack trace to the developer, which will give him a clue about what the problem is. I never got one stack trace, so I had absolutely nothing to go off of. I have 4 different Android devices I test against I have not ever been able to reproduce this issue. In some cases I’ve had customers reach out to me by email asking what the deal is… and I’ve never had a good answer for it… Until today. Continue reading ‘Unity Android and the Android Market Licensing (LVL) – a cautionary tale…’