How to divide character body?

Started by
1 comment, last by Irlan Robson 10 years, 7 months ago

Hello!

So, I'm making a 2D platformer in C++ with SFML. To animate my characters I used a sprite sheet where each frame has a fixed size and each line of frames is associated with a movement (for now, they are IDLE, WALK, and JUMP)

Now I got to a point where I need the head of the character to rotate, and I'm having a hard time on figuring out a nice way to divide the body in separate pieces and draw them togheter.

Can someone help me on this?

Thx! smile.png

Advertisement

I imagine you're already doing this, but have one instance draw all the pieces of their relative body. Don't have an instance for each piece.

As for the drawing of pieces, if you're using OpenGL, you want to rotate the piece first by the pieces desired rotation( the unique rotation of the head indifferent from the body ), translate the piece to the center of the instance, rotate again to the instances desired rotation( so rotating the entire character rotates the head with the rest of the body ).

If you have any specific questions, ask away as I'm not entirely sure how you're going about attempting to achieve your goal.

For animation switching: States (dead state, walking state)

A "Scene Graph" in 2D (it's possible) it's definitely what you need. Just Google It! Your code will be more Object Oriented and more reusable too. cool.png

This topic is closed to new replies.

Advertisement