Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm quite new to game development, so would like to get a consensus on methods of doing this.

My game features a 2D character that is able to pick up and drop objects, for example, a stick. My question is: is it advisable / possible to manipulate the image of the character and image of the stick to make it look like the character is now carrying a stick; or is it best to have a separate sprite sheet for the character with the stick and the character without?

EDIT:

To be clear - I have a lot of characters, with a few items (4 separate items and over 20 characters)

share|improve this question

marked as duplicate by bummzack, Byte56 Dec 9 '13 at 18:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Up to you. Custom sprites for a pickup states may be difficult to do if you have a ton of items. You can also go halfway. Put objects into a few generic ways to hold them: hold a handle for things like axes, bats, and shovels; hold with two hands for heavy objects like rocks, boxes, and cannonballs; and drag if large like a sack, sled, or small child (jk). Evaluate your need. If the character only ever holds a few items, maybe it will look better to have custom carry sprites. Or if you have a ton like Terraria then SPIN THAT SWORD! –  mobo Aug 9 '13 at 12:51
1  
You'll want to setup a character skeleton. This can be referred to as "animation by parts", where a character has a set of hierarchical transforms. Example: The sword will be at position (5, 0) relative to wherever the player is. The sword will be a separate image, so that you can swap the sword out without making new character art. –  RandyGaul Aug 9 '13 at 22:05

3 Answers 3

It will depend a lot on the artwork and what effect you want to accomplish and how much time you want to spend on it.

Do you need the to work with every single object? Or just some wieldable ones (like swords and sticks). If its just some then I would probably just have a separate set of sprites.

If you are looking to do rotations on pickup and you are doing pixel art (via a pixmap/bitmap image) then manipulating the original image won't work very well. It will possibly blur (if you have some kind of antialiasing) or it might loose a lot of detail (if there is no antialiasing pixels can disappear or 'tear').

You could try using much higher resolution graphics or even better (but much more complex to program) vector art, so manipulations don't have as many visual issues.

A simple 90° bitmap rotation would work without any distortions. It could allow the stick to be flat on the ground and upright when held, 45° wouldn't be too bad either. But some items won't make sense (a cup of water might look weird when left on the side), so you might need to provide a rotation 'hint' with the sprite/object.

You will need to track the location of the hand, you might also need to have some bits that are drawn under the item or over it. For example fingers. It might also be reversed when the character is facing the other way.

It might be an idea to have some rigging like you would with a 3d mesh. For a simple setup, I would probably make a separate character sprite (or another layer) that just has a couple of pixels in a few color keys. The Red pixel might be the left hand position. Blue for right. You can add other colors for things like the head, torso, legs, knees, feet and so on which would allow things like helmets, armour, pants, shoes and so on. Just scan though the pixels for the 'slots' (there are probably more efficient ways of packing it, but don't make more work for yourself). You might also be able to use different colors to specify if the object should be drawn after to before the character sprite (ie will the hands obscure the object). You could make a fingers a separate 'object' if you need that level of complexity (ie the fingers drawn over the object but the palm of the hand behind it).

Otherwise if you just need a few specific items, swords and such rather than every object in existence I would probably just have a animation for 'guy with sword' 'guy with axe' 'guy with stick' and so on. Maybe just have them overlay the generic 'guy' character sprites. But remember an attack animation with a sword will probably be different to one with an axe so setting up some overly complex setup would just get in the way their.

Maybe you can offer some colour pallet options so you could have a wooden sword or a steel one with the same sprites just with different colours.

share|improve this answer

The way we do this in our 2D MMORPG is to use the following approach:

  • Two base character models
  • Weapons go on their own layer
  • Animate the weapon for all the same frames as the character model

To accommodate different kinds of weapons, we use different animation states. So we have Idle - Fist Weapon, Idle - Sword, Idle - Staff, etc.

The result of our approach is a high degree of flexibility, but it also means a lot of work. We have to animate every weapon in the game for every (applicable) animation state of our characters. We also have to do this for armor, etc.

We try to minimize this work as much as possible, but it's still there.

In short, if you want a believable result in your game, you're probably going to have to do something along these lines or tailor your art very carefully and think about using some kind of animation system. We just use frame-by-frame animation.

Hope this helps at least a little bit. Good luck!

share|improve this answer

you can have:

  • separate sprite with stick.
  • hands with stick, that are attached to body.
  • some skeleton, and then draw stick where the hand is.
share|improve this answer
1  
This is very vague. Can you explain skeleton and what each of these things are used for? –  Byte56 Aug 9 '13 at 13:09

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