Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am developing a 2D platform game in Java. The player has a gun in his hand every time. He needs to walk and shoot with the gun(arrow keys for walk and X key to shoot). The walk cycle takes 6 frames and i am able to import the sprite sheet and animate the sequence when I press arrow key. But i need to add the gun motion. The player holds the gun upwards and when X key is pressed he brings it straight and shoots. How to implement the walk + shoot action?

share|improve this question
What does your player's sprite look like? Is it all one piece, or is it split up e.g. into torso, legs, arms? In any case, take a look at this blog post. – user14497 Mar 23 '12 at 20:03
@K.G. The player sprite is one piece. – Praveen Sharath Mar 23 '12 at 20:15
up vote 12 down vote accepted

The player sprite is one piece.

Then either:

  1. The sprite needs to not be one piece. Split it into two sprites and render them that way. The top and bottom halves can animate independently sometimes but dependently other times. See Contra.

  2. You need special frames of sprite animation for walking and shooting simultaneously.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.