Quantcast
Channel: Pixi.js Latest Topics
Viewing all articles
Browse latest Browse all 3978

AnimatedSprite single pass

$
0
0

Hi,

I was trying to make my AnimatedSprite run only once. Initially I thought it could be achieved by setting `loop` to `false` and manually calling `play()`. However that worked only first time. For instance, I wrote code to run the animation once when mouseover. Later on when the animation is over I would take my mouse elsewhere and then bring it back over the sprite to trigger animation again, but this time it wouldn't play. After lot of experimentation I figured out that I have to call `gotoAndStop(0)` in the `onComplete` callback to achieve what I wanted.


let animSprite;

// Load animSprite

animSprite.loop = false;
animSprite.gotoStop(0);

animSprite.onComplete = function () {
  animSprite.gotoAndStop(0);
};

animSprite.play();

Is this the right way to achieve single-pass animation?


Viewing all articles
Browse latest Browse all 3978

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>