I am porting an AGS game to iPhone, and was wondering what the best approach to the port would be?

How best would you structure your code and assets?

More specifically, how would you deal with say 100+ scenes. My initial approach is to create a scene superclass with things common between all scenes, like backgrounds, music, doors, windows, characters. Then for each scene an inherited version of that superclass with more particular things like checks, dependencies etc. Upon entering the scene, you'd check for dependencies and go from there. This is all off the top of my head mind you, so probably forgetting quite a bit.


1 Answer 1


Chances are, there are no (maybe one or two hobby ones) 'mature engines' for iPhone point-and-click.

However, Cocos2D iPhone has a high level of abstraction, so it should be easy enough to use that.

As for code structuring, that's really up to you. I personally would have a system where:

  • The background is just a static image.
  • Items are graphically static on the background, but in code they exist with a position and general rules for combining. So a lamp at (x,y) would receive the touch there and do whatever it has to.
  • If an object is on the screen, it could have checks for 'am I being used with object X?' and 'has event Y happened?'. This indicates you would need a set of event flags, muchlike an RPG. Something like 'has player opened secret door', 'has player killed bad guy', 'has player unlocked safe', etc.

EDIT: Following your edit, Cocos2D has its own Scene class. This can quite easily be derived from, and would save significant time from having to develop a whole scene object.

As for doors, I would treat them as a separate object. If you give each object the player as a parameter when you press them, you could simply have pressing a rock call player.add_item(this), and a door player.setzone(scene.leftexit).

I wish you luck with your project.

  • \$\begingroup\$ Good suggestions, but how would you organize those 3 bullet points at a higher level. That's fine for a few little scenes. But for 100+, you'd need a more organized structure. \$\endgroup\$ Commented Jan 19, 2011 at 18:09
  • \$\begingroup\$ Cocos2D itself has a structure of using Scenes and transitions between them, so that takes a lot of the work for you. Backgrounds could be stored in a texture atlas if you wanted. And how much more organized do you want that a Lamp, which has a description when you press it? And event flags are a good way to run things - not only is there the check(Player_Found_Door) way, but as the flag is set in a function you can change all the items you need then. \$\endgroup\$ Commented Jan 19, 2011 at 18:33
  • 1
    \$\begingroup\$ I've heard tons of great stuff about using cocos2d for any 2d iphone game. \$\endgroup\$
    – Dream Lane
    Commented Jan 21, 2011 at 21:21
  • \$\begingroup\$ Try Kobold2D (kobold2d.com) - it's an improved Cocos2D engine with more sample code and easier to get into. I'm the author so take it with a grain of salt, but it's also what my users are saying. :) \$\endgroup\$
    – CodeSmile
    Commented Sep 14, 2011 at 9:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .