play animation on iphone game? - iphone

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

Related

Why use Cocos over UI Kit for a 2D iPhone game?

I have been building a game in cocos for a while now I it has just occurred to me that it might just be a whole lot easier to use UIKit.
Could you please help me weight up the pros and cons, and share some experiences you have.
Here is my basic list of advantages for each. I feel I dont know enought about cocos to make a informed decision which is best.
Cocos
Game engine comes for free. Pause / resume callbacks every frame
Sprite animations
Uses open GL (is this true? is this an advantage?)
...Help me think of some more!
UI Kit
Far more Help / Documentation / Sample Code
Familiar for iPhone programmers
Easy to handel touch
Easy view animations
Easy to customise
Faster loading times? (is this true?)
Any feedback would be great!
EDIT: I have just seen a developer video (on an open GL game called Quest) where they used UI Kit for the UI elements, drawn over the top of the GL View. Is this possible / practical with cocos?
Cocos2d uses OpenGL for drawing its sprites, movements, and particles. Trying to use Quartz/Core Graphics (which is NOT accelerated!) is fundamentally much slower and power hungry.
Cocos2d is a sprite library with a scenegraph first and foremost. You would be duplicating effort to make a scenegraph using UIKit.
There are lots of nice freebies that work within Cocos which you would have to develop from the ground up.
So, in short: It draws way faster than CPU bound drawing calls, it provides 95% of what most sprite based games need without reinventing the same thing over and over, and is free.
Although UIKit is incredibly useful for gaming, Cocos2D offers a variety of easier ways to accomplish many common game-making operations. For instance, it has the ability to create easy scrolling-tile games (very common and very popular) using a simple few lines of code to import a "Tiled" map set. In terms of some of the benefits of UIKit over Cocos2D that you mentioned, they are very easy to accomplish in Cocos2D, as well.
Touch handling:
This is as easy as replacing the "touchesBegan" method of UIKit with "ccTouchesBegan" and setting self.isTouchEnabled = YES in the init method.
Animations:
This is so much easier in Cocos2d, mainly because frame rate and animation issues are solved. In UIKit, you cannot use CoreAnimation to move an object while still implementing collision detection. You would have to animate the object with an NSTimer. In Cocos2d, you can easily animate objects (called sprites) and still use collision detection and interaction with the object.
More Help/Documentation:
Cocos2D offers an incredible amount of documentation and, even more so, examples of code! If you can't find it there, there is a growing number of iPhone game developers who implement Cocos2D in their apps and are willing to help many problems.
If you are planning on developing games for iPhone, and not just general apps for productivity, music, etc., I highly suggest Cocos2D. Remember, you can always still find ways to combine this and UIKit for many operations! Those operations aren't completely lost!

Right tool for the job: CoreAnimation, Cocoa Animation, or OpenGL ES?

I am relatively new to doing graphics work on the iPhone and was hoping to get some guidance on which technology I should employ. The issue I am facing is that I need to create an iPhone app that will have a spinning wheel in it, think the Price Is Right wheel.
I am not looking for anyone to provide a detailed solution, that would spoil my fun! I would simply like to know would it be better to use straight Cocoa Animation and draw and move each cell by hand as the wheel spins, or should I attempt to use Core Animation Layers? I have also thought of using OpenGL ES and building a true cylinder in 3D and then rotating that, this seems the most logical to me but again I am new to all of this.
For situations like this, I usually recommend looking first to Core Animation and only going to OpenGL ES if you can't get the kind of performance you need. Redrawing a wheel frame-by-frame using only Quartz will result in abysmal performance, so that's not really an option here.
Using Core Animation, you can perform complex animations, such as your rotation, without requiring much code. You also can leverage UIViews and other UIKit components to provide touch interaction easily. You don't even necessarily need to step down to using layers, as every UIView is layer-backed and they tend to be pretty lightweight.
OpenGL ES will give you the best possible performance, but I wouldn't think you'd run into a limitation when simply spinning a wheel using Core Animation, even on older devices. OpenGL ES will require a lot more code to achieve the same effect, and will be more difficult to integrate with any touch interaction you may wish to do.
Based on the feedback I have dug deeper into Core Animation and have been able to accomplish what I need using it. Thanks for all the advice.

Could you recreate the 3D page turning effect seen in the iBooks app using only Core Animation or would you need to use OpenGL ES?

I read an article somewhere explaining that apple uses OpenGL ES to implement the page turning effect in the iBooks app. Since you can perform 3D animations on 2D Layers using only Core Animation, what might be some reasons you'd have to use OpenGL ES to create that page transition animation?
Thanks in advance for your thoughts!
Steven Troughton-Smith has accomplished this here without OpenGL. http://blog.steventroughtonsmith.com/2010/02/apples-ibooks-dynamic-page-curl.html
However, he uses Private APIs, so you may want to be careful.

2D Game Character Animation in iPhone - How is it done?

What I mean is, do animators work on an animation in say Flash (or some other kind
of key frame animation program) and then export it to the iphone somehow?
For example, say I am an animator and I want to create a person waving for an iphone
game. What type of external program would I use and then what libraries on the iphone
sdk would I use to load them in?
I think it all depends on how in depth you want to get. Making a 2D game is a broad statement. For example, to make what you ask. You would just make a series of PNG images for a cell based animation of the wave. wave1.png, wave2.png, waveN.png...
Then load the PNG images in and then play them in sequence. You can do this with UIImageView, Core Animations classes, or manually your self with UIImages and UIViews.
There a lot of great game engines you can check out too. Here is a link for an example of what is available. Game Engines
For the best performance, most companies/developers use OpenGL to do both 2D and 3D style games. You can utilize a lot of tricks for the textures used in your games.
The iPhone natively supports key frame animation with the CAKeyframeAnimation class.
I think the most popular framework for 2D games is Cocos2D: http://cocos2d.org/

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.