Converting UIImage animation to use Cocos2d sprite animation - iphone

I have an app that uses UIImage animation, and the timing of the animation is inconsistent. I would like to convert over to using sprite animation with cocos2d.
Can I add this functionality to my existing project? Are there any good tutorials on how to add Cocos2d to an existing project?

I've seen people just use Cocos2D inside an EAGLView with good results. This fellow seems to have got it working. Having said that, I would probably try to optimize your UIImage animation. Using PNGs is generally faster, and try to scale your animation image frames to the exact display size. And, make sure your animation frame rate isn't above 30 or so.

Related

play animation on iphone game?

I want to do a simple game but full with animation in the start and the middle of the game.
my question is:
What is the best way to play the animations?
I am good with Adobe Flash and can do my animations on it.
can I benefit from it, or is there another way to do that.
thanks for all answers, but my main question is it efficient to play video instead of sequence of images, or is there a way to play the flash video, to like the image sequence with the volume.
will suggest you to use the CoreAnimation framework that have in-build animation support, most of the animations can be accomplished by CoreAnimation.
Here is the Apple tutorial guide to CoreAnimation .
Core Animation Programming Guide: Introduction to Core Animation.
Recommended Reading for iPhone Core Animation
You can use cocs2d framework for designing game with different animations.
Are you talking about cut-scene animations or sprite animation? Video is definitely going to be more efficient than frame sequences for a cutscreen animation. You could build you animation and export to video from Flash if you are good with it. If your talking about sprite animations, as Anish said, Cocos2d has really fast sprite sheet support. Here's a good intro:
http://www.raywenderlich.com/1271/how-to-use-animations-and-sprite-sheets-in-cocos2d

Performance Gain Using Multiple CALayers in One UIVew

I'm in the process of writing a simple 2D game which at present does a fair bit of custom drawing for multiple sprites upon each update - i.e. I have game view that delegates to all sprites to perform quartz rendering (point/line based) upon each update.
My performance is ok upto around 50 active objects being rendered but now things are starting to slow down so I'm looking to optimize. To do so I've decided to pre-render my sprites to a CALayer then add that to the game view.
My first thought was to give each Sprite instance a CALayer which is added to the GameView's view.layer as sublayer. This would mean that I use a single UIView which has multiple CALayers - one per game sprite.
Would there be a negligible performance loss if I decided to use a UIView for each game sprite?
UIViews are part of the responder chain and will add extra overhead. I started with UIViews for sprites and found gestures became sluggish.
I would recommend sticking with CALayers
As far as I know, UIViews are pretty lightweight wrappers around CALayer, so the performance loss shouldn't be too big. But I think a sprite would simply be better represented by an instance of CALayer rather than UIView.

How do I draw a new image without making a new UIImageView

I have a character in an iPod Touch game I am making that moves around the screen. That I have under control... However I want him able to shoot fireballs, and I don't want to have to make a new UIImageView for every fire ball he shoots. I have the image and everything... I think i need to use quartz core or openGL ES, but I can't make sense of the apple documentation.
Another option would be to implement drawRect in your view, and draw the fireballs there.

Playing 3D Animation in iPhone App (Possibly using a looping video)

Is there a relatively easy was to include a 3D animation into an iPhone app? We have the animations already made up for another project and our client has asked if they can be placed inside an iPhone app. We could perhaps include a low-res looping video of the animation (it's just a 3D component rotating on a single axis), or would it be better to look into getting the 3D animation directly onto a view?
Cheers,
Dan
You could either split it up into a set of frames and use the UIView animationImages property like so:
http://appsamuck.com/day2.html
Or assuming its already an OpenGL animation you could port the code to openGLES.
Here are good tutorials for openGL ES:
http://iphonedevelopment.blogspot.com/2009/05/opengl-es-from-ground-up-table-of.html

Why is manually moving a UIImageView slow?

I am trying to write a head-to-head iPhone Air Hockey (like) game. When the user touches the screen I move the "puck" by placing the UIImageView center where the touch center is.
Also I move the puck (another UIImageView) using a timer. This method is slow and shaky. I know I can get performance out of OpenGL ES but I do not want it to get that involved if I can help it.
I would also like to take advantage of the animation engine for special effects and such. How can I manually move the paddles and puck to a timer and get better performance. Or do I just have to embrace OpenGL ES for this?
Or do I just have to embrace the OpenGL?
No there is a middle ground: CoreAnimation.
Matt Gallagher has a demo game (for Mac) which uses Core Animation to display sprites. You will not see the same performance on iPhone as desktop but, your game is much simpler than his example.