masa Posted May 9, 2015 Share Posted May 9, 2015 I'm creating action game like FinalFight by capcom.When I touch button , I want punch animation play just one time. but in my case, punch aniamtion is looping, while I keep pressing button. how can I solve it.thanks.function create(){// Create virtual controller buttonA = game.add.button(600, 400, 'buttonA', null, this, 0, 1, 0, 1); buttonA.fixedToCamera = true; buttonA.events.onInputOver.add(function(){punch=false;}); buttonA.events.onInputOut.add(function(){punch=false;}); buttonA.events.onInputDown.add(function(){punch=true;}); buttonA.events.onInputUp.add(function(){punch=false;});}function update(){if(punch) { player.animations.play("punch", 9, false); } } Link to comment Share on other sites More sharing options...
drhayes Posted May 11, 2015 Share Posted May 11, 2015 When the player holds the punch button down your code sets "punch" to true. That means that it'll keep playing the punch animations for as long as the player is holding the button down, regardless of whether that last argument is false or not. The code in your update method makes sure of that. You probably need to do something where you set punch to false after you start the animation playing, maybe? Link to comment Share on other sites More sharing options...
Recommended Posts