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 04-05-2011, 10:22 PM   #1 (permalink)
Registered Member
 
Mattonaise's Avatar
 
Join Date: Apr 2011
Posts: 12
Mattonaise is on a distinguished road
Question Core Animation Architecture in Games?

Hello forum...
I am new to this forum and to iphone development in general, so any helpful tips would be much appreciated.

My question is about using CALayers in simple 2d games, and about their performance as well. The design of the game in my head is very simple graphics-wise, so I think CALayers would be able to handle it. There is only going to be about 8-9 objects moving on the screen at any one time, so not very complex (no particles or animations either). I just want some input on if this would be acheivable easily with CALayers, as Opengl ES would take up too much of my time to implement right now...

The implementation of CALayers also brings up a few questions. I wouldn't subclass CALayer to create the game object classes, as I am planning to keep the game entities and data away from the CALayers to keep the code as clean and flexible as possible. What I mean is to have a seperate class holding the game data, and keep the CALayers for the game objects in a game UIView subclass. The game UIView subclass would have a reference to the game data instance (they could possibly both exist in a uiviewcontroller class, MVC?), so that every time the screen needed to be updated, the view could look up coordinates of game objects in the game data instance and set the CALayer coordinates to match that. I am planning to have different "themes" in the games for the graphics (neon, doodle, space, underwater,...), so I thought this architecture would let me change the images pretty easily. Another thing is that if this app was to become Universal, I would only need to have a different subclass of the game UIView (one for iphones, another for retina display, and one for ipad) and only need to change the game data class slightly (really just screen sizes and coordinates) in order to be able to run the app on different devices. Is this a good and flexible way to approach the architecture of the code? Any advice is very helpful.

However, one question about this architecture is that whether it would be better to update the CALayer coordinates every frame (and possibly need to use setneedsdisplay?) or to use an animation from one place to different coordinates 5 frames later, as the first option may cause performance difficulties. But there is some simple circle-to-circle physics in the game, so animations from place to place may not look so realistic. Again, any input will be helpful.

I hope the post was easy to follow , i tried to cram a lot of stuff in there so Im not sure if it was explained very well. So feel free to ask me any questions you may have.
__________________
A 14 year old app developer...god help me...
Mattonaise is offline   Reply With Quote
Old 04-05-2011, 10:57 PM   #2 (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

I'm not sure the added complexity of CALayers is worth it, since you still won't get the speed of OpenGL / Cocos2D. I'd either stick with UIViews or go straight to Cocos.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 04-05-2011, 11:10 PM   #3 (permalink)
Registered Member
 
Mattonaise's Avatar
 
Join Date: Apr 2011
Posts: 12
Mattonaise is on a distinguished road
Default

I suppose, but I dont really think there is any added complexity with CALayer, except maybe with animation. I have heard though that CALayers do have a bit better performance than UIViews as CALayers dont repond too touch events and the like, but I could easily be wrong. The reason I dont really want to use OpenGl is just because I think its a bit overkill for the game, and it may be more time than its worth.
__________________
A 14 year old app developer...god help me...
Mattonaise is offline   Reply With Quote
Reply

Bookmarks

Tags
architecture, core animation, game development, performance, universal

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: 434
7 members and 427 guests
chemistry, Emy, hussain1982, mistergreen2011, Retouchable, skrew88, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,922
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:16 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0