On Wed, Jan 21, 2009 at 4:32 PM, Hordeling <[email protected]> wrote:
>
> I hate to admit this, but I come from old school game development (c.
> 1989) and am used to processing game data in an update loop or idle
> event.
>
> I'm trying to figure out the best way to approximate this in cocos2d.
> Looking at pyglet, I could override the window idle function but that
> seems pretty heavy handed.
>
> I'm happy using the event model that exists for handling *UI* in
> cocos2d
>
> But what is the best way (aside from an MVC model, please not that) to
> get regular updates for processing game data? Ultimately, my ideal
> update event would get the delta time, process game data accordingly,
> then allow cocos2d/pyglet handle all the scene graph drawing on its
> own.
>
> Would the cocosnode schedule function would be the right place to
> start?
>
> If so, what does 'every frame' mean in the context of the callback?
Every frame means after each screen redraw. Cocos works like this:
- setup
- while not exit:
- handle event
- update world model
- draw frame
So, every frame mean each iteration of this while loop.
I dont quite get what you are trying to do, but usually the functions
i need to call to get the world running are scheduled on the __init__
of the scene that requires that.
For example, a level scene can schedule the "step" function like this:
class LevelScene:
def __init__(...):
...
self.schedule(self.step)
def step(self, dt):
# your code
This way, whenever the LevelScene scene is on stage (being rendered)
the step method will be called with the dt parameter being the amount
of time that elapsed since the last call to step or since the scene
(re) entered the stage.
Regards,
Lucio.
when i want some
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cocos2d discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cocos-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---