From the documentation page:
================================================================================
SPEnterFrameEvent
In some game engines, you have what is called a “run-loop”. That’s a endless loop which constantly updates all elements of the scene. In Sparrow, due to the display tree architecture, such a run loop would not make much sense. You separated your game in numerous different custom display elements, and each should know for itself what to do when some time has passed.
That’s what the EnterFrameEvent is for. It’s available in any display object, and is dispatched once in every frame. Here is how you use it:
// e.g. in the init-method
[self addEventListener:@selector(onEnterFrame:) atObject:self
forType:SP_EVENT_TYPE_ENTER_FRAME];
// the corresponding event listener
- (void)onEnterFrame:(SPEnterFrameEvent *event)
{
NSLog(@"Time passed since last frame: %f", event.passedTime);
[enemy moveBy:event.passedTime * enemy.velocity];
}
The method ‘onEnterFrame:’ is called once per frame, and you receive the time that has passed since the last frame. With that information, you can move your enemies, let snowflakes fall down just a little further, etc.
======================================================================================
I have difficulties implementing this function into my code. I want to use it to move sprites up or down.
This is how it looks like in cocos2d
==========================================================
// schedule a repeating callback on every frame
[self schedule:@selector(nextFrame:)];
// floor
- (void) nextFrame:(ccTime)dt {
seeker10.position = ccp( seeker10.position.x , seeker10.position.y + 100*dt );
if (seeker10.position.y > 480+32) {
seeker10.position = ccp( seeker10.position.x, -32 );
}
}
==================================================================================
How would one go by achieving this in Sparrow? Anybody has some code example laying around?