Aicha Posted April 27, 2021 Share Posted April 27, 2021 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++) { console.log(array); switch (array[i]) { case left: { this.player.setVelocityX(5); player.anims.play('left', true); break; } case right: { this.player.setVelocityX(5); player.anims.play('right', true); break; } } } } 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 comment Share on other sites More sharing options...
Recommended Posts