On Sun, Apr 29, 2012 at 5:57 PM, Pascal LE MERRER <[email protected]
> wrote:
> I would like to have a callback to be invoked when a layer becomes
> visible, and another one to be invoked when it become invisible.
> I thought overriding the 'on_enter' and 'on_exit' methods would do the
> trick, but it appears they are invoked more than once :(
> A solution for me could be to be notified of the end of the transition.
>
> What is the best way to achieve this?
>
>
To be notified at the end of transition you could do:
def get_transition_scene(fn_callback):
def helper(self):
super(TransitionSceneWhatever, self).on_exit()
fn_callback()
trans = TransitionSceneWhatever()
trans.on_exit = helper
return trans
This can be a bit before you really want to receive the call, so maybe this
can work better
layer_to_notify = MyLayer()
layer_to_notify.after_transition = False
def get_transition_scene(layer_to_notify):
def helper(self):
super(TransitionSceneWhatever, self).on_exit()
layer_to_notify.after_transition = True
trans = TransitionSceneWhatever()
trans.on_exit = helper
return trans
Now in layer.on_enter you can check the flag to know if the transition
ended.
claudio
--
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.