Created
December 31, 2014 17:43
-
-
Save andykorth/0d415a17424a1cd48678 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// scheduling test object: | |
- (void) setupScheduleCallbackTimeTest | |
{ | |
// Test pausing the content node with extra parent nodes. | |
self.subTitle = @"Andy is cool"; | |
CCSprite *sprite = [SchedulerTestSprite spriteWithImageNamed:@"Sprites/bird.png"]; | |
[self.contentNode addChild:sprite]; | |
// ********************************* | |
[sprite schedule:@selector(scheduleMe:) interval:0.1f repeat:99 delay:0.1f]; | |
// ********************************* | |
} | |
// Other methods, printing update time, etc | |
-(void)update:(CCTime)delta | |
{ | |
// update: moves left and right | |
_updateTime += delta; | |
NSLog(@"Update called with dt=%f time=%f", delta, _updateTime); | |
CGPoint pos = self.position; | |
pos.x = 360 + 30*cos(_updateTime); | |
self.position = pos; | |
} | |
-(void)fixedUpdate:(CCTime)delta | |
{ | |
// fixedUpdate: moves up and down | |
_fixedUpdateTime += delta; | |
NSLog(@"Fixed Update called with dt=%f time=%f", delta, _fixedUpdateTime); | |
CGPoint pos = self.position; | |
pos.y = 160 + 30*sin(_updateTime); | |
self.position = pos; | |
} | |
-(void)scheduleMe:(CCTime) t | |
{ | |
NSLog(@"Scheduled selector called #%d with t=%f", calls, t); | |
calls += 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment