Jump to content

play another sprite when currently playing sprite's reaches to some specific frame


aida
 Share

Recommended Posts

Hello,

I have 2 sprite animations. Once first one is played, via below function I'm checking frame index (which frame is currently playing). When current frame is my desired frame, I want to play another sprite.

animations.currentAnim.onUpdate

Below is my full code:

firstSprite.visible = true;
firstSprite.animations.currentAnim.enableUpdate = true;
firstSprite.animations.play('firstSprite', 14, false);
firstSprite.animations.currentAnim.speed = 80;

firstSprite.animations.currentAnim.onUpdate.add(function () {
    if(firstSprite.animations.currentAnim.frame > 5){
        secondSprite.visible = true;
        secondSprite.animations.play('secondSprite', 30, false);
        secondSprite.animations.currentAnim.speed = 60;
    }
}, this);

On desktop in a browser it works perfectly, but on mobile devices it is being stucked and once frame is greater than 5 (if(firstSprite.animations.currentAnim.frame > 5){...}), then it stops at that frame and doesn't continue to play first sprite. Is there something I'm missing.

Thanks

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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