Hello,
I'm in the process of making a cheesy little action game, but I have a question about what would be the better way of implementing taking and giving damage.
What I'm looking to do when either my player is shot, or an enemy is shot, is to have him slid back a step or two... you know, sort of a blowback from the hit.
Is that the kind of thing I would use a cocos action for, and set the position back a number of pixels and give it a fraction of a second runtime, or should I be doing something different?
Right now, I have a class that has an instance of a CCSprite, and an enumerator for the guy's state - so like, normal, attacking, takingdamage... something like that. Each update, I call an update method on each player or enemy, which will check the state and do something. Currently, when someone gets damaged, he'll just slide back in the opposite direction of where the player/enemy is, and it will count the updates and after a certain amount of time, switch back to his normal state and resume walking/attacking or whatever.
It feels like a bit of a kludgey way to do it, so I'm just wondering if it is in fact not a great way, and what I could do instead.
Thanks,