Jump to content

sprite animation doesnt work properly

Recommended Posts

Hello everyone , im sorry for my english  so im pretty new to phaser3 and i want to create  educational coding game for kids using typescript ,the kid should drag the arrows and drag them into places and then hit the button run so i declared an array  to stock every arrow (image) that he dropped and then when run is clicked,  i itterate the  array and in function of the image's name the sprite get animated 

my code looks like this :

//paly is the run button //
    this.play.on('pointerdown', () => {

      for (var i = 0; i < array.length ; i++) {
        switch (array[i]) {
          case left: {

            player.anims.play('left', true);
          case right: {
                player.anims.play('right', true);
          } }

the images are stored but when i hit run the sprite is animated by the last animation like if my array is like this   {'left','left','right'}  just the right animation is getting excuted ,please im stuck help me !!! 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...