Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-28-2011, 09:08 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 38
cegarrison is on a distinguished road
Default Architecture concerns

Hi,

I am developing a 2D game. My game architecture uses an OO design with each scene being a sub class of GameScene. I also use singletons for state management. So for the scenes, I funnel all the touches into the current scene. However, I am finding myself using several IF statements and BOOL variables to handle the dynamics of each scene such as touch locations, whether an item has been discovered, etc. I am wondering if anyone can reassure me that this will perform well or if it is a common problem that has been solved already. I am still early in development and want to get this architecture right.

Thanks in advance!
cegarrison is offline   Reply With Quote
Old 02-28-2011, 09:33 PM   #2 (permalink)
Registered Member
 
missing_no's Avatar
 
Join Date: Feb 2011
Posts: 41
missing_no is on a distinguished road
Default

what do you mean by "OO design" you're going to be dealing with object oriented programming no matter what way you shake it...

The most important thing I've learned is to use lazy function calls (when possible), remove, retain and release objects and allocate memory properly. It's going to be hard to slow down the A4 with just a 2d game.
missing_no is offline   Reply With Quote
Old 02-28-2011, 09:58 PM   #3 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

Performance is probably not a big concern; drawing will probably be slower than all of your game state code put together. Maintainability may take a hit though.

Can you give an example of the kind of if/then constructs you're using? Big if/then trees are usually *eliminated* by good OO design.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 02-28-2011, 10:25 PM   #4 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 38
cegarrison is on a distinguished road
Default

So within the screen I am saying there are 15 "selectable" areas. When drawing, I have a if/bool for 15 items drawn in these areas when they aren't moving (in their original position). Then I have 15 more "ifs" when they are moving, with touches moved updating the X,Y. and when isMoving bool, it draws as the user moves the item. And not to mention an animation happens when touches ended... that is IF it is ended in the correct XY coordinate, which varies on each 15 items.
cegarrison is offline   Reply With Quote
Old 02-28-2011, 10:54 PM   #5 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

Sounds like you need to refactor those selectable areas to be objects of their own - then you can keep an array of them and loop through it. Now you only have one if statement for each test instead of 15. That seems like a much cleaner design.
__________________

Free Games!
smasher is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 424
7 members and 417 guests
chemistry, ChrisYates, hussain1982, Retouchable, skrew88, SLIC, xzoonxoom
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,921
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:13 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0