Createjs tweens execute once per window session and never run until page refresh

127 Views Asked by At

I'm trying to run code that tweens a stage child at the end of every minigame. I have several minigames with different tweens. The idea is that when you complete some goal with said minigame, a tween will run that plays some kind of animation. Unfortunately, when one tween runs, the rest in any minigame never execute. This also goes for the initial minigame: when one tween from minigame A runs, all the tweens in minigame A don't run. The only way to get tweens working again is to refresh the page, but even then, the problem will still continue.

I have these lines of code running globally in a file called universalDeclar.js that's read before any other js file besides the createjs cdn

createjs.Ticker.timingMode = createjs.Ticker.TIMEOUT;
createjs.Ticker.framerate = 24;

When I instantiate the new game, I give a specific child (for this case, a Sprite named professor) a tween animation before its added to the stage but don't play it until some condition is met in a later function, to which I write stupidTween.paused = false;

stupidTween = createjs.Tween.get(professor, {paused: true}, true) 
  .to({x: 700 }, 400, createjs.Ease.linear)

After running stage.update() in the initialize function, I always reset the ticker (since I plan on implementing time limits for each minigame) and call on a new function to run every tick

createjs.Ticker.reset();
createjs.Ticker.addEventListener("tick", fillTick);

Any guidance or help on this problem would be really appreciated since a lot of my games rely on tweenable animation

1

There are 1 best solutions below

0
Fabian Bautista On

Fixed the problem myself. Apparently calling createjs.Ticker.reset(); prevents any other tweens from reoccurring despite functions being initialized with every new minigame load. I had to create some new variables to manage time differences between games but everything works now