Question about addEventListener()

I am BEGINNER…
Sorry to ask I know its kind of beginners question but I am actually stuck with it here is my problem:
I have a Sprite-sheet set and in the stage I have 3 buttons each does walk left,walk right and last button does the action like attack etc.
I am able to use listeners to walk left and right but the last button to do action like multiple punches how?I am able to add a listener while I walk from left to right to do punch but as soon I walk from right to left?and press the button it still does the punch from left to right and I want form right to left???
if I walk left to right I need a right punch
if I walk right to left I need a left punch

BUT its only ONE button do I need multiple listener for one button if so (HOW)
can someone give me an example code for this problem I have!!

Thank YOU…
[import]uid: 122701 topic_id: 23520 reply_id: 323520[/import]

Have a variable, eg;

heroFacing = “left”

When you press the left arrow;
heroFacing = “left”

When you press the right arrow;
heroFacing = “right”

and then for the punch button use an if statement;

[lua]if heroFacing == “left” then
–code to punch left
elseif heroFacing == “right” then
–code to punch right
end[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 23520 reply_id: 94415[/import]

Thank you so much
It worked super …
now that it work last question hope you could help as well
and its:
Can physics works with sprite-sheet?
I tried right but for some reason it gave me the complete box
I did the debug mode in physics and I don’t get it or do you think
its not possible or is there a trick to it?
I’m still super new…

Again
Thank you for the last question!

[import]uid: 122701 topic_id: 23520 reply_id: 94958[/import]

Hey there,

Glad I could help :slight_smile:

For the physics, sprites can have bodies, yes.

They will have the “complete box” but you can do a custom body to give it a different shape if you want. (We have documentation about this.)

Peach :slight_smile: [import]uid: 52491 topic_id: 23520 reply_id: 95098[/import]