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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 06-01-2009, 07:26 AM   #4 (permalink)
Jason Rogers
Registered Member
 
Join Date: May 2009
Posts: 97
Default

I read about coco2d really quickly (I'll need to do some opengl in in a couple of weeks so I'm reading up)

if your using coco2d as your main framework you might want to check out there version of the timer

BestPractices - cocos2d-iphone - cocos2d for iPhone best practices - Google Code

Code:
    * Try not to use Cocoa's NSTimers. Instead use cocos2d's own scheduler.
    * If you use cocos2d scheduler, you will have:
          o automatic pause/resume.
          o when the Layer (Scene, Sprite, CocosNode) enters the stage the timer will be automatically activated, and when it leaves the stage it will be automatically deactivated.
          o Your target/selector will be called with a delta time

            /**********************************************************/
            // OK OK OK OK OK
            /**********************************************************/
            -(id) init
            {
                    if( ! [super init] )
                            return nil;

                    // schedule timer
                    [self schedule: @selector(tick:)];
                    [self schedule: @selector(tick2:) interval:0.5];

                    return self;
            }

            -(void) tick: (ccTime) dt
            {
                    // bla bla bla
            }

            -(void) tick2: (ccTime) dt
            {
                    // bla bla bla
            }

            /**********************************************************/
            // BAD BAD BAD BAD
            /**********************************************************/
            // Why BAD ?
            // You can't pause the game automagically.
            -(void) onEnter
            {
                    [super onEnter];
                    timer1 = [NSTimer scheduledTimerWithTimeInterval:1/FPS target:self selector:@selector(tick1) userInfo:nil repeats:YES];
                    timer2 = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(tick2) userInfo:nil repeats:YES];
            }
            -(void) onExit
            {
                    [timer1 invalidate];
                    [timer2 invalidate];
                    [super onExit];
            }
            -(void) tick
            {
                    // bla bla bla
            }

            -(void) tick2
            {
                    // bla bla bla
            }
it seams to add a few insteresting functionalities that you need when doing 3D programing and you dont want to dig in the code to much.

otherwise as I guessed a sprite is a UIView with extra functionalities ^^
I tend at the moment to try and write the low level stuff by hand and get my own framework of classes and functions going but that a lot of work

maybe if I get round to coco2D you can help me out

best regards

jason
__________________
We all have to go down this same road.
You liked it when the ones in front of you helped.
So think about the ones behind you.
---
try, try again, try some more, then ask.
once you asked, continue trying until you find a solution.
and finally make sure you post the solution.
Jason Rogers is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,671
Threads: 89,155
Posts: 380,385
Top Poster: BrianSlick (7,110)
Welcome to our newest member, sukhdip
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:35 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.