one key at a time!
Posted: Sun Jul 25, 2010 6:03 pm
I'm making a game in which the charactor is seen throught a top-down perspective.
I want him to move up, down, right, and left, but only move one direction at a time - not diagonaly.
How can I prevent other keys being pushed down while one of the other three is pressed?
Also, when I hold a button (up, for instance) then press another button, right, then let go of the up button, my charactor moves right as it should, but the animation still shows him walking up. I think this is because, for the change animation effect, it only detects the keydown initially (repeat is disabled) while the x and y movment itself is constantly updating. The animation is several frames long, so I can't make it update constantly. Or could I- is there a way to detect whether or not the actor is already playing an animation so it would not re-change animation every frame?
It is more of a trivial asthetics problem, not vital to the gameplay, but I would appreciate any responces!
(by the way, should this be posted under general or support?)
I want him to move up, down, right, and left, but only move one direction at a time - not diagonaly.
How can I prevent other keys being pushed down while one of the other three is pressed?
Also, when I hold a button (up, for instance) then press another button, right, then let go of the up button, my charactor moves right as it should, but the animation still shows him walking up. I think this is because, for the change animation effect, it only detects the keydown initially (repeat is disabled) while the x and y movment itself is constantly updating. The animation is several frames long, so I can't make it update constantly. Or could I- is there a way to detect whether or not the actor is already playing an animation so it would not re-change animation every frame?
It is more of a trivial asthetics problem, not vital to the gameplay, but I would appreciate any responces!
(by the way, should this be posted under general or support?)