A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Platformer sword attack?

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    23

    Platformer sword attack?

    I NEED HELP!

    I'm in the middle of creating a platformer, and in one section of the game the character picks up a sword. The problem is, I don't know how to get him to use it. I want to press "Spacebar" and he slashes with his sword. I am also going to animate three different attacks with the sword (For example jab, slice, and slash).

    I want to press spacebar once and the character does "Attack 1." Press it again and he does "Attack 2" and etc. So what is the coding for all of this?

    If somebody could resolve this I would be more than thankful.

  2. #2
    Senior Member
    Join Date
    May 2009
    Posts
    138
    Well, it really depends how you're doing it. If your player is a movieclip and your attack animations are all on one timeline, you can do something like have a variable called attackFrame and set it to the first frame of "Attack 1". Then, have some actionscript in the "Attack 1" sequence set it to the first frame of "Attack 2", and so on. Then when the spacebar is pressed, just use gotoAndPlay(attackFrame).

  3. #3
    Junior Member
    Join Date
    May 2010
    Posts
    23
    Quote Originally Posted by redjag View Post
    Well, it really depends how you're doing it. If your player is a movieclip and your attack animations are all on one timeline, you can do something like have a variable called attackFrame and set it to the first frame of "Attack 1". Then, have some actionscript in the "Attack 1" sequence set it to the first frame of "Attack 2", and so on. Then when the spacebar is pressed, just use gotoAndPlay(attackFrame).
    Alright so if I did it that way, what would the coding look like for "Attack 1?"
    (I understand what you're saying but I'm not good at variables.) Only Attack 1 though because it would just be the same coding for the rest except for swapping names and keyframe numbers. Thanks a bunch.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center