Scene transitions and on_enter/on_exit

37 views
Skip to first unread message

Richard Jones

unread,
Jan 15, 2009, 3:53:13 PM1/15/09
to cocos2d discuss
I'd really like for scene transitions to not generate those extra
on_enter/on_exit events. Does this bother anyone else?


Richard

Lucio Torre

unread,
Jan 15, 2009, 4:17:56 PM1/15/09
to cocos-...@googlegroups.com
On Thu, Jan 15, 2009 at 6:53 PM, Richard Jones <r1char...@gmail.com> wrote:
>
> I'd really like for scene transitions to not generate those extra
> on_enter/on_exit events. Does this bother anyone else?

you mean the ones that you get when the scene is no longer the main
scene, and then its a child scene, so you send the events again?

how do you plan on doing it?

Lucio

Richard Jones

unread,
Jan 15, 2009, 4:29:13 PM1/15/09
to Lucio Torre, cocos-...@googlegroups.com

Both the entering and exiting scene get an addition on_enter/on_exit. If
there's an enter and exit transition then there would be three
on_enters/on_exits for a given scene which is really only being displayed
once.

It means the semantics of on_enter and on_exit are muddled. What does an
invocation of them really mean?

How do you handle animation timing which should start "when the scene is
displayed"? How do you handle setting up expensive resources which shouldn't
be loaded outside of "when the scene is displayed"?


> how do you plan on doing it?

No idea at this point.


Richard

Lucio Torre

unread,
Jan 15, 2009, 4:36:54 PM1/15/09
to Richard Jones, cocos-...@googlegroups.com
On Thu, Jan 15, 2009 at 7:29 PM, Richard Jones <r1char...@gmail.com> wrote:
> On Fri, 16 Jan 2009, you wrote:
>> On Thu, Jan 15, 2009 at 6:53 PM, Richard Jones <r1char...@gmail.com>
> wrote:
>> > I'd really like for scene transitions to not generate those extra
>> > on_enter/on_exit events. Does this bother anyone else?
>>
>> you mean the ones that you get when the scene is no longer the main
>> scene, and then its a child scene, so you send the events again?
>
> Both the entering and exiting scene get an addition on_enter/on_exit. If
> there's an enter and exit transition then there would be three
> on_enters/on_exits for a given scene which is really only being displayed
> once.

So, lets imagine we want to display a scene with an enter and exit
transition, we get:
start entenr transition: on_enter
end enter transition: on_exit, on_enter
scene runs..
start exit transition: on_exit, on_enter
finish exit transition: on_exit

you would like it to be:
start entenr transition: on_enter
end enter transition:
scene runs..
start exit transition:
finish exit transition: on_exit

>
> It means the semantics of on_enter and on_exit are muddled. What does an
> invocation of them really mean?

it means that the scene has entered or exited the 'stage'
the stage being whatever is being drawn at the moment.

>
> How do you handle animation timing which should start "when the scene is
> displayed"? How do you handle setting up expensive resources which shouldn't
> be loaded outside of "when the scene is displayed"?

being able to remove a scene and put it back on is useful for many
features of cocos, like transitions and pause.
if you need expensive precomputing done, use __init__

as dt is only fed to the scene when its on stage, you dont have to
worry about animation times and stuff like that.

>
>
>> how do you plan on doing it?
>
> No idea at this point.

This is the part that scares me. I understand this model and i like. I
think that just one enter/exit pair for transitions would be nice, but
im not sure i want to pay the cost.

Lucio.

riq

unread,
Jan 15, 2009, 4:40:54 PM1/15/09
to cocos-...@googlegroups.com
I would like also like to have only one on_exit & on_enter when doing
the transitions.
Although I understand why and how it works, it is confusing for some
developers (including some cocos2d-iphone developers).


riq.

--
http://blog.sapusmedia.com
http://monodiario.blogspot.com

Winston

unread,
May 18, 2012, 2:53:35 PM5/18/12
to cocos-...@googlegroups.com
This is an old thread, but I found it when searching for how to tell when on_enter() is called from a transition versus from my actual scene starting. I'll post the answer for the next person. In your on_enter() method, when "director.scene != self", then you might be in a transition.
 
-Winston 
 

Ryan Hope

unread,
Nov 8, 2012, 6:51:28 PM11/8/12
to cocos-...@googlegroups.com
Awesome, I also needed this info!

Ryan Hope

unread,
Nov 10, 2012, 3:05:33 PM11/10/12
to cocos-...@googlegroups.com
I have a slightly better solution:
 
When isinstance(director.scene, cocos.scenes.transitions.TransitionScene) is True you are in a transisiton :D
 
This works in layers and scenes.
Reply all
Reply to author
Forward
0 new messages