You have a tilemap and you want physics collisions on it? The solution seems obvious: create a rectangle shape for every blocking tile.
But ouch! This solution is not just hugely wasteful and unnecessarily slows down the physics collision code, it also introduces the well known problem of characters getting stuck even on flat surfaces.
This is in particular a problem for Box2D because its collision mechanic doesn’t work well with flat surfaces subdivided into smaller segments (rectangle shapes in this case).
A workable but still very awkward solution to work around this behavior is to create characters with bevelled edges at the character shape’s bottom at the risk of bopping characters as they walk about the map.
Lupines in the Moore Neighborhood
A good solution to generate physics collisions is to implement the Moore Neighborhood algorithm to generate chain shapes which are more suitable for tilemap collisions. The downside is that adding or removing individual blocking tiles at runtime requires updating the shapes - this is not implemented in this project.
Every flat surface, no matter how many tiles form the surface, will then consist of only one straight collision segment. Here’s a quick demo video of the project discussed in this post that shows the algorithm at work and the resulting “game”:
This is a guest post by Nat Weiss, author of the cocos2d-iphone RPG Game Engine and the cocos2d-x Paralaxer Game Kit. Today he shares his experience working with the two most popular cocos2d game engines, and explains how and where they’re different.
He also needs more beta-testers for his latest game: Awesome Heroes Arena.
Over the last year, my bro Kristopher Horton and I have been developing a realtime Multiplayer-Online Battle Arena (MOBA) game for tablets with cocos2d-x. The game’s called Awesome Heroes Arena and we are finally at the point of taking on beta testers: here’s the beta sign up if you are interested.
Steffen thought it would be interesting if I shared some thoughts on switching from cocos2d-iphone to cocos2d-x. What’s it like? What things do I miss?
Why did we choose cocos2d-x?
I am so very happy to … no, actually I’m relieved Kobold2D is working fine again with the latest Xcode 4.6, including iOS 6 autorotation fixes and the FIX_CATEGORY_BUG issue. Being happy is reserved for whenever I’ve added something nice to KoboldTouch.
Of course I updated cocos2d-iphone to version 2.1-rc0a (on first sight that version looks like being encoded in hexadecimal). Which meant I also had to update cocos2d-iphone-extension to whatever is the current development version - which must be somewhat above 0.21 but that’s hard to tell because there’s no reference of a version number anywhere.
Also updated Chipmunk (6.1.2) and obviously that had to be followed by updating Chimpunk (oh there it is again - my favorite typo today) SpaceManager v0.2.01.
Lastly Admob was playing hard to catch. And it has grown awfully huge, comes with several of Google’s other SDKs as well. Given the dwindling interest in ads by game developers I just pulled the plug and removed AdMob. You can still add it back in to your project according to Google’s instructions though.
That said, here’s the download link for Kobold2D v2.1. Here’s the link to the Release Notes.
I’ll make another update when cocos2d 2.1 is final. The next version is dated for “March” according to the Changelog, but that’s going to be another release candidate. I didn’t want to hold off on updating Kobold2D for the cocos2d 2.1 final version.
PS: There won’t be anymore updates to the Kobold2D v1.x branch.
I added two additional Plans to KoboldTouch:
- NEW: 1-Month Support & Updates: $19.95
- 3-Months Support & Updates: $39.95 (same as before)
- NEW: 12-Months Support & Updates: $119.95 (4 quarters for the price of 3)
All plans are now non-recurring / not auto-renewing. No more subscription plans.
The 1-Month plan is for trying out KoboldTouch, or getting or updating it cheaply. Lowering the barrier of entry. I want to increase the user base to gather more feedback, requests and suggestions.
The 12-Month plan is for supporters and early adopters who are willing to invest into KoboldTouch while saving money in the long run.
Note: You can continue using and publishing apps built with KoboldTouch even after your support & updates plan has expired.
Learn more about KoboldTouch and sign up.
Target Audience
At this point KoboldTouch isn’t for everyone (yet). I decided to narrow the focus to the type of users I seem to have convinced and the type of users I like to work with and attract more. I summed it up like so:
KoboldTouch is a custom-built game engine for demanding iOS & Mac OS X developers.
I’m currently working on a new tilemap renderer for KoboldTouch.
I now have an early version that’s fairly complete and does most of what cocos2d’s tilemap renderer can do. Pun intended: yes, cocos2d’s tilemap renderer really doesn’t do all that much: load and display tilemaps with multiple layers.
In fact my current implementation is one step ahead already:
KoboldTouch’s tilemap renderer doesn’t require you to use -hd/-ipad/-ipadhd TMX files and the related (often hard to use or buggy/broken) TMX scaling tools. Just use the same TMX file designed for standard resolution, then simply provide just the tileset images in the various sizes with the corresponding -hd/-ipad/-ipadhd suffixes. The tilemap looks the same on a Retina device, just with more image detail.
Performance Comparison
Anyhow, I thought I’ll do some quick performance tests. I have a test map with 2 layers and a tiny tileset (3 tiles, 40×40 points). I’m comparing both in the same KoboldTouch project, using the slim MVC wrapper (named KTLegacyTilemapViewController) for cocos2d’s tilemap renderer CCTMXTiledMap. Continue reading »