double action: you can add a conditional in the on_enter so the action is
activated **only in one** of the cases
- top scene is a transition
- top scene is not a transition
You can detect if called while in transition by
is_transition = isinstance(director.scene, cocos.scenes.TransitionScene)
memory leak: good catch.
The more direct fix would be to add
dst.parent = None
before
director.replace(dst)
But a more robust fix can be done by changing director._set_scene by adding
a
scene.parent = None
just before the line
self.scene.enable_handlers(True)
This way no matter what a custom transition does, it can't break the
contract "top node has parent None"
What do you think ?
On Sat, Oct 10, 2015 at 5:25 AM, Daniel Gillet <[email protected]>
wrote:
> Hello,
>
> I see some problems with the Scenes transitions. First here is what I'm
> trying to achieve. Imagine a Layer (let's call is static) in a scene. You
> can transition to another scene with another layer (let's call it action).
> This action layer has some actions that should be run when the layer comes
> into play.
>
> So I thought I would launch my action in the `on_enter` method. But with
> the scenes.transitions, it turns out that when creating the scene for the
> transition, the action layer gets its `on_enter` method called. So it
> starts doing its thing while the scenes are transitioning. When the
> transition is done, the director replace the transition scene with the new
> scene containing our action layer. So its `on_enter` gets called again!
>
> Here is a quick demo. You can go from scene 1 to 2 with or without
> transition. Notice that without transition the label jumps twice while
> shaking a bit. If we use a transition, it appears while already jumping and
> jumps more than twice (because of the second call to `on_enter`).
>
> See code here: https://gist.github.com/dangillet/cbd23d5ec4162e960eff
>
> Also I think there is a memory leak! When the transition is completed, if
> you look at the new scene (containing the action layer), you will notice
> that it still has a parent (a scene) which has also a parent (the
> FadeTransition scene) ! Indeed, when the transition finished in
> cocos/director.py we call `director.replace(dst)` but we never delete the
> `self.parent` attribute.
>
> Dan.
>
> --
> You received this message because you are subscribed to the Google Groups
> "cocos2d discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/cocos-discuss.
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"cocos2d discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cocos-discuss.
For more options, visit https://groups.google.com/d/optout.