How to create a sword attack after a button is pressed on the scene?

memski425memski425 Member Posts: 19
edited August 2012 in Working with GS (Mac)
Hello,
i was wondering how to make a sword attack after pressing an attack button. I am not very sure how to start rule wise.
Thanks in advance :D

Comments

  • RPRP Member Posts: 1,990
    How far along are you with your controls? Do you mean you need the sword actor/animation to appear when the attack button is pressed?

  • memski425memski425 Member Posts: 19
    i already created my button i am just looking where to start rule wise and animation wise :D
  • MotherHooseMotherHoose Member Posts: 2,456
    @memski425

    add a gameAttribute: boolean type … name attack

    on buttonActor:
    Rule: when
    Event: touch is pressed
    -changeAttribute: game.attack To: true

    on playerActor:
    Rule: when
    Attribute: game.attack is true
    -Animate: drag in 4-8 images

    and rule or behavior to change the attack to false …

    Ex: Timer: After: 1 second
    -changeAttribute: game.attack To: false

    image MH
  • BurkiousBurkious Member Posts: 29

    Great advise MotherHoose! Thats exactly what he must do.

  • BurkiousBurkious Member Posts: 29

    The question now is how to make the sword actually hurt the enemy. Maybe... invisible actor?

  • TosanuTosanu Member, PRO Posts: 388

    Yes. What you need to do is first have a set of game attributes watching the player X and Y position. You then, at the same time in the rule as the animation, spawn an actor, invisible. Thsi actor will need to have its starting position held to a position relative to the PlayerX and Y. It also will need to have instructions to move itself to match the sword's movement, to damage enemies that impact them (however you want to set that up, it could be an enemy actor reaction (if collides with sword) or so on), and to have a timer to destroy itself at the end of the action.

Sign In or Register to comment.