Show a sprite before changing scene

  ... discussions about development with the GLES2 branch of AndEngine.

Show a sprite before changing scene

Postby jgibbs » Sun Mar 11, 2012 1:22 pm

I'm trying to implement a very simple 'Loading...' image over the top of a scene as my next scene loads.

I have pre-loaded the sprite, attached it to the scene and set it to !visible. At the point where I load up the new scene I'm changing it to visible so that my user knows they pressed the button and to please be patient.

Problem is the dropping of the current scene appears to be happening before my sprite can be displayed.

Is there any way I can delay in my loader function until the sprite is showing without getting into callbacks etc? Looking for a very simple way to do this if I can.

Thanks
Check out my adventures into Android programming:

4x4 Adventures - Featured in the Top Free Play Store listings
Slippery Sid
jgibbs
 
Posts: 105
Joined: Fri Nov 25, 2011 9:32 am
Location: New Zealand

Re: Show a sprite before changing scene

Postby reittes » Sun Mar 11, 2012 2:00 pm

Hi,

i had same kind of problem, and I solved it with a simple workaround which works for me, for now. What I did was, I separated the Scene2 into two functions- void loadScene() where I do all works done in onLoadScene, and another is public Scene runScene(), just to return the scene.

At Scene1, when the button to switch to Scene2 is tapped, I call loadScene, make the "loading..." visible, register a TimerHandler with 1-2 secs delay, let the scene load, then call runScene().

Hope it works for you as well.

Regards.
---------------------------------------------
My Apps: https://play.google.com/store/apps/deve ... eizon+Apps
reittes
 
Posts: 59
Joined: Tue May 24, 2011 4:56 pm

Re: Show a sprite before changing scene

Postby jgibbs » Sun Mar 11, 2012 10:56 pm

Thanks for that. My current temporary solution is pretty much what you just described, but I was looking for something that I didn't have to force a delay on. However while reading your post it dawned on me that the TimerHandler takes a float for the delay time. I hadn't remembered that and was causing a 1 second delay where the actual change might have been much less. I've dropped my wait back to something that's imperceptible and this seems to be acceptable now.

FYI, my method simply has a 'loading' sprite sitting waiting in the background of the scene I'm changing from so there's no double scene handling. That was what I was trying to avoid because most of my scene changes are between menus and I don't want the user to have to wait while just setting up their game.
Check out my adventures into Android programming:

4x4 Adventures - Featured in the Top Free Play Store listings
Slippery Sid
jgibbs
 
Posts: 105
Joined: Fri Nov 25, 2011 9:32 am
Location: New Zealand


Return to GLES2

Who is online

Users browsing this forum: apenzzi, bruno.gabriel, Google [Bot] and 44 guests