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

Recommended Posts


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.


Below is my full code:

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

firstSprite.animations.currentAnim.onUpdate.add(function () {
    if(firstSprite.animations.currentAnim.frame > 5){
        secondSprite.visible = true;'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.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.