You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tween._inited does not reset if scene is being destroyed or removed inside the game and rebuild #92
I have written a game using easeljs + preloadjs + soundjs + tweenjs.
The scene order like this:
I used the same canvas for different scene. Promo Scene -> Start Game Scene
Every time finishing the game, the restart button will go to Promo Scene again.
I found that probably(I haven't dig deep enough to find out) I use stage.clear(), stage.removeAllEventListeners() and so on.
The Tween ticker is somehow being removed from the scene.
So, first run, everything is fine, afterward, the Tween does not run unless I set Tween._inited = false before anything start again. Since the big Tween is supposed to be added once as tick function according to the source code logic.
I add this in restart game logic createjs.Tween._inited = false; as workaround.
Since _inited is undocumented due to it is an internal property.
I think it is an issue for restarting everything, in the above situation, but not necessarily a bug.
I have been dealing with the same issue. This is what happens:
Our game is over, so we destroy everything and call Ticker.reset
All 'tick' event listeners are removed BUT Tween._inited is still true
When we start a new game and try to create a new tween, Tween thinks it's initialized but there is no 'tick' listener on Ticker.
@simongcc has a solution, I have solved it differently, by explicitly setting Tween._inited = false when we destroy our game, because registering a new tween automatically adds the 'tick' listener if _inited is false.
However, setting protected properties like that is not recommended practice. I would humbly request the devs to create a public Tween.reset() or something similar.
Activity
spassvogel commentedon Jun 2, 2017
I have been dealing with the same issue. This is what happens:
Tween._initedis still true@simongcc has a solution, I have solved it differently, by explicitly setting
Tween._inited = falsewhen we destroy our game, because registering a new tween automatically adds the 'tick' listener if _inited is false.if (!Tween._inited && createjs.Ticker) { createjs.Ticker.addEventListener("tick", Tween); Tween._inited = true; }However, setting protected properties like that is not recommended practice. I would humbly request the devs to create a public
Tween.reset()or something similar.