Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 06-01-2009, 06: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
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,267
Threads: 39,062
Posts: 171,292
Top Poster: smasher (2,575)
Welcome to our newest member, nvrendingsoft
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:53 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.