Jump to content

Animations get faster switching scenes


blade2xs
 Share

Recommended Posts

I have an old school RPG I am making and I have two main scenes, the Overworld and Encounter scenens.  The overworld is fine when switching to it but the problem is the Encounter, before I switch to it, I reset it so I can recreate it from scratch with a random monster in it.  The problem is, every time I switch/restart the Encounter scene, the animation of the creature gets progressively faster.

I do remove the animation key so I dont get the warning when I switch back to the Overworld scene.  Just curious if I am taking the right approach to this and if so, do I need to clean up the sprite of the monster before hand so it doesn't make the animation speed up?

Link to comment
Share on other sites

I have a similar problem, and what I'm encountering is that the gravity is getting bigger and bigger when the scene is switched, and I suspect it's a BUG.
I am a temporary solution for switching scenarios  ,Give it a try 

this.scene.resume('xxx')

 

Link to comment
Share on other sites

15 hours ago, blade2xs said:

The problem is, every time I switch/restart the Encounter scene, the animation of the creature gets progressively faster.

I had this problem too, momentarily. I think it's related to the scene switching, not the animation itself.

Link to comment
Share on other sites

Thanks guys,

This partially worked.  I ran a series of tests and, apparently, when the the scene preload and create methods get re-run, it is the culprit with increasing the animation speeds.

I say partially worked with the resume because I am stuck with the first creature I randomly created for the initial scene call...  I am working on a way to run a method in the scene to reinitialize the animations for the new creature.

Link to comment
Share on other sites

Ok I solved it in a kind of hacky way... not super please but it works... I'll note it in a TODO in my code when I post it to github.  Basically I follow the advice here and had to set up all monster animations possible for the scene, then just before restarting the Encounter scene, I have to manually call a function to change the sprite animation and had to save the context of the encounter scene globally otherwise all the "this" references break... I'm not super happy with it but I have a deadline to meet and it works.

A nice to have would be some documentation on the best practice for switching between scenes like this.

Link to comment
Share on other sites

  • 3 years later...

Hi, 

I found that this is happening when a scene is sleep and is started again. To avoid this, I use scene.stop() and scene. start() or scene.restart() to switch between scenes. Each time the scene is started, it will run faster, until crahses.

In my case, when I was clicking the menu button in the game scene, I was calling sleep() instead of stop(). So when I was starting the game scene, it was running faster an faster.

Just in case this helps.

Regards.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...