Tetris is playable, but this code is barely working, to be honest. I haven’t played with it on a device yet, and I know there are cases in the rotatePiece method that haven’t been tested. I’ve got the next piece in the game model, but not showing up in the view. I was going to use Sneaky Input for the controls, but I ended up scrapping it and just using some really simple touch-based control instead.
Someday (hopefully soon-ish), I’ll be writing a blog post titled “how to write tetris in Objective-C using Cocos2D”. I’ll try and clean it up a bit then.
I think my session was recorded, possibly by folks at the Uptake, but I have no idea if that recording is online (as a few others from the event are). If it was, I’ll definitely update this post to link to it, since these slides are pretty useless without my running commentary. There are some nice links in a “Resources” section in the last few slides, so you can enjoy those if nothing else.
UPDATE: I just posted a link to the sample code for this talk on github in a new blog post. The code shows various examples of how to do really basic things in Cocos2D, including using the schedule method to create a game loop, using the CCMenu class, drawing various particle types, and finally, how to write tetris in Objective-C using a Cocos2D texture atlas for the different piece types.
A few weeks back, I upgraded to Snow Leopard, and noticed I no longer had the option of choosing 2.0 through 2.2.1 as my active SDK. I was starting a new project, and didn’t worry about it, thinking I’d figure it out later.
Well, now it’s later, and I spent the last hour or so figuring this out, so I thought I’d post it here in case someone else finds this helpful.
In the apple dev forums, I found a couple of people suggesting you need to re-install the old versions of the dev tools, then move my Developer directory, and re-install the latest tools. This seems silly, since I still have the “/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk” directory. It’s possible this suggestion is in order to get the old version of the simulator, although I’m not entirely sure why you’d want to have that.
Another helpful commenter said “Base SDK does not set compatibility. It sets your available feature set. The iPhone OS Deployment Target build setting controls compatibility. Set it to 2.0 or 2.2.1 to allow your app to launch on earlier OS versions.” That made much more sense to me, but I couldn’t immediately find the “iPhone OS Deployment Target” setting in my project settings. I did have it though, it just wasn’t showing up for some reason. When I finally searched for IPHONEOS_DEPLOYMENT_TARGET it showed up, and with a handy dropdown full of old SDK versions.