Press button switch animation?

Press button switch animation?
0

#1

I created 2 animation / idle and skill.
I created a struct player with bool idle = true and skill = false.
When I click the button, I pass the idle to false and the skill to true. but it does not work
it was not active. me as newbie.help me
player


#2

help me !!!


#3

You haven’t pasted enough of the surrounding code, such as where you check for the idle and the skill members of the player struct, or where pl is defined and how it’s used.

Some suggestions:

  • Open up a debugger, add breakpoints, and step through the code to actually see what is going on.

  • Add CCLOG("…") calls anywhere you think is appropriate to know what is going on and the value of the fields, such as:

    CCLOG(“pl.idle status: %d”, pl.idle);

Other than that, from the bits of code you have pasted, the way you’re dealing with such things is perhaps not the best. When you push a button, you’re setting “skill” to true, yet when you release the button, you’re setting it to false and setting “idle” to true, which is almost instantaneous, assuming you press and release the button quickly.

I’m certain that isn’t the only issue with the code, and you may need to read up on structuring game code. I don’t really have any links I can give you at the moment that may help, but I’m certain there are plenty of resources out there to gain an understanding of how a game is structured, such as the main loop, updating, events and such.