0
\$\begingroup\$

I am new to cocos2D development. Basically I want to develop game in which i want to move sprite forward with walking kind animation, must look real. Any help will be appreciated.

\$\endgroup\$

closed as off-topic by concept3d, MichaelHouse Jan 6 '14 at 15:38

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about "how to get started" or "what should I learn next" cannot reasonably be answered with anything other than opinion polling and therefore are off topic for the site. For more information on how to ask a better question, see the help center" – concept3d, MichaelHouse
If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ define "real" .. \$\endgroup\$ – LearnCocos2D Jan 6 '14 at 10:17
1
\$\begingroup\$

Basic sprite animation is really simple:

int frame_to_play = (game_tick * target_fps / tick_rate) % number_of_frames;

The result will tell you which frame (the frame_to_play-th) to show.

game_tick would be some kind of frame counter that just counts up (has to tick at least as fast as your animation is meant to be played).

target_fps is the framerate at which your animation should play (this must not be larger than tick_rate).

tick_rate is the amount of increments to game_tick per second.

number_of_frames is really just the number of frames in your animation cycle.

Note that this will create a linear/repeating animation (i.e. no partial loops or "ping pong" playback). If you want something else, you'll have to add some more logic.

How to make it look right/real? That once again requires some experimentation: Experiment with the speed your character moves (most likely something fixed/predetermined) as well as the framerate of your animation.

\$\endgroup\$

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