tags:

views:

2248

answers:

2

I am trying to animate a sprite. The cocos2d website makes it look so easy but everytime I try it I get errors. I managed to download some code to get it working but one sprite animation takes 6 files. I have a character that needs to walk right and left, jump, climb, and fall. That means I am looking at 35 files. can't it be streamlined a bit? It just seems way harder than it should be.

Thanks, Josh

+2  A: 

Cocos is great. You just need to spend time with the demo project, hang out on the message board, and keep at it.

You animate a sprite like this:

id action = [Sequence actions:
    [ScaleTo actionWithDuration:.3 scale:0.7f],
    [ScaleTo actionWithDuration:.3 scale:1.0f],
    nil];

[[self getByTag:FOO] do:action];

This causes the sprite with the tag FOO to scale down to 70 percent in .3 seconds, then back up to 100 percent in .3 seconds.

Much more complex animations are possible, just get the basics down and the world will be ya oyster, at least as far as making stuff fly around on the screen, that is.

Genericrich
I think by animation he means e.g. how do we display a sequence of images to create a smooth video e.g. a person walking?
Seun Osewa
A: 

Cocoa With Love have a short-series on writing a came using CoreAnimation, perhaps it might be of use?

Cocoa does take a lot of getting used to, and does seem really overly convoluted, but when you compared it to.. well, most other GUI toolkits I've used, it suddenly seems very elegant and simple. The problem with the example code, and most tutorials (including the one I linked to, albeit to a slightly lesser degree) is they only show you the finished application - it doesn't show the increments. There's no "I have a empty canvas", then "I worked out how to draw a circle", then "I've animated the circle".

Try making a new application, look through the example code/IB project/tutorials/documentation for the bit that initialises the canvas-thing. Then look for the code that adds a simple shape. Then look for the code to animate the code (Genericrich answer, for example)

dbr