Jump to content

Hit an enemy animation, collision and looping problem


vernonr
 Share

Recommended Posts

Hello again. New problems arise everyday! I have a character who has an animation called "hit". Here's the strip of frames.

 

post-11774-0-63315800-1417303149.jpg

 

So in my code I have this little something that makes the character "hit" when the btnGolpe is down:

 

btnGolpe = game.input.keyboard.addKey(Phaser.Keyboard.M);
 
in function update ():
 
else if (btnGolpe.isDown) {
player.animations.play('golpe'); 
}

 

The problems?

1) The animation keeps looping if btnGolpe is down. It should only play once per button pressing.

2) I need that the character actually "hits" it's opponent with his fist. Is there a way to do this? The collision should be between the fist and the opponent. Bare in mind that the fist is shown in one frame of the whole animation, so it show only register the collision in that frame, in that position (the fist, in this case).

 

I'm really looking forward for your advise on these things. Thanks in advance, people!

 

Link to comment
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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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