Started coding cocos2d myself, one of the first things I got stuck is
sheduling function calls to the future.
I searched for a callLater method in the layers (à la twisted), but
didn't found it. No problem, I thought, I always can schedule a
function to the future, and then unschedule the function inside
itself.
Something like
"""
...
self.schedule(self.func, delta_time)
def func(self, delta_time):
self.unschedule(self.func)
"""
But, this broke my code, in the following situation: I had a lot of
sprites, and during some analysis, I do an action on some, and then
schedule for later some logic. The problem is that I schedule "func"
several times, but the first time "func" is called, it unschedule
itself, so it's only called *once*.
I quickly fixed this issue creating a "call_later" method:
"""
def call_later(self, dt, func, *args, **kwargs):
def f(dt, args, kwargs):
self.unschedule(f)
func(*args, **kwargs)
self.schedule_interval(f, dt, args, kwargs)
"""
The question is... does this exist and I didn't find it? if not, why
doesn't it exist? Is not usefule normally?
Furthermore, it could be useful a more-like-gtk schedule function [0],
that keeps calling the function until it returns False.
What do you think about this?
Regards,
[0]
http://www.pygtk.org/docs/pygobject/gobject-functions.html#function-gobject--timeout-add
--
. Facundo
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---