animate images in cocos2d - core-animation

I am newbie in cocos2D But have developed several view based application.
So what I want to know is:
Is there any alternate ,for animationImages used for animating the images in imageview, in cocos2D?
I want to use the same thing i.e: Animate the images same as any gif file.
Thanks in advance....

Animation in Cocos2D is handled by the CCAnimation class, you can read the documentation here:
http://www.cocos2d-iphone.org/api-ref/latest-stable/interface_c_c_animation.html
There are a number of examples for animating sprites, using a Sprite Sheet, single Images, a Texture Cache, etc.
This is one of my favorite ones:
http://www.raywenderlich.com/1271/how-to-use-animations-and-sprite-sheets-in-cocos2d

Related

Animating OpenGL content within a Cocoa OSX Application

I am currently attempting to create an interactive, informative poster, with regards to Anti-Aliasing techniques and effects. The application is written in Obj-C within Xcode, and makes use of OpenGL and Cocoa functionalities.
I am attempting to create a small animation to display the difficulties of drawing a diagonal line on a pixel grid, however am having real trouble getting my head around the animation aspect.
I am aiming for something with a similar look and feel to this:
I have currently drawn a grid using OpenGL primitives:
,
and would like the effect above to be replicated within my grid, however without the shading yet (that is the next part), so just plain black pixels coloured step by step along the line.
I am new to both OpenGL and Obj-C, so am unsure whether best to implement the animation within OpenGL, or using OSx Core Animation - neither of which I have used before.
The OpenGL drawing takes place within my MyOpenGLView class, with the drawing done in a drawAnObject method, which is then called within the drawRect method.
Any help would be much appreciated, thanks in advance!

Create an image cropping interface for Objective C (Mac OS X)

I need to create a very simple image cropping interface for an OS X cocoa application, but I am not sure where to start. The user needs to be able to choose a crop size from a menu of presets, be presented with a cropping rectangle that can be resized preserving the ratio, and moved around the image until they finally apply the selected crop to the image.
I've done some searching for sample code and projects but not found anything too useful. Core Image fun house has some pointers but is a retired sample. There are lots of iOS examples, but I've not found an easy to follow Mac OS example.
Can someone point me in the right direction (or at a sample project or framework!!).
Thanks a lot.
Here is a project you can look at:
https://github.com/foundry/drawingtest
It's a little demo I made as I was trying to understand the relationship between the rects in this method:
- (void)drawInRect:(NSRect)dstRect
fromRect:(NSRect)srcRect
operation:(NSCompositingOperation)op
fraction:(CGFloat)delta
Note that the older compositeToPoint: methods are deprecated and should not be used for this sort of thing.
srcRect is the portion of the original image (in it's own coordinates) that you want to keep.
dstRect is the rect that you want that cropped area to draw into.
JMRect in the project is an NSObject representation of an NSRect - so that we can use cocoa bindings to tie the interface controls together.
For your UI, the cropping rectangle could just be a transparent subview view with a border that you push around and resize over the image you want to crop.
This is by no means a complete solution to your question, but it's something you can poke around with - it might help you to get started.

iOS: how to add "cartoon" style animation (movie) to the slide?

I'm wondering if it's possible to have a slide with text AND add some animation into it for an iPad app. See screenshot below to get an idea of what I need. I want that guy jump up and down and smile. I'm sure I'm not capable of drawing that image using Objective-C primitives myself, so I'm looking at the following options:
Do complete animation in 3rd-party tool (Adobe?) and then add it as single standalone file on the slide. But I do not know, what formats are supported in iOS, what are standard formats, and, at the end, how to insert that file on the slide. Can somebody clarify this please?
Do complete animation, and then save frames as images, and then quickly change images to give illusion of a movie.
Am I missing something? Are there any other ways? what's the best option?
Please let me know if I'm not clear enough - I will try to provide more information.
Thank you.
If you want to use a movie file for the animation, you can find the supported video formats in the iOS Technology Overview, under “Media Layer > Video Technologies”. You will need to use an AVPlayerLayer from the AVFoundation Framework to show the video.
If you want to use a separate image file for each frame, you can use one of the +[UIImage animatedImage...] methods to create an animated UIImage, and display it in a UIImageView.
If you want to use a single animated GIF for the animation, you can use this public domain UIImage+animatedGIF category to load the GIF into an animated UIImage, and display it in a UIImageView.

8192x8192 UIView Lag

I'm making a game using UIView.
I use a large (8192x8192) UIView as the map area, (the game is birds-eye-view) with a UIImageView stretched across it displaying a grass texture.
This uses heaps of memory, doesn't run on older devices and nearly crashes Xcode whenever I try to edit it...
Is there an alternate method of creating a 8192x8192 map, but without being laggy?
If it's possible to tile your graphics, something involving CATiledLayer would probably be a good fit. CATiledLayer allows you to provide only the images that are necessary to display the currently viewable area of the view (just like Maps does).
Here is some example code for displaying a large PDF.

Objective C iPad Animation with large images - What method to use?

I'm trying to build a weather application on the iPad but it seems that I need some help in animation. Say I'm animating a Radar, so the radar source files have 10 gif/jpeg pictures in 900x700 pixel size. I've tried the UIImage animation technique using the tutorial here:
http://www.icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/
but it seems that loading 10 images that big is too much for the iPad to handle and its crashing due to memory warnings. I'm researching other techniques to animate but I can't seem to find something that will do this efficiently.
I've looked at others like Core Animation using sprites, and Cocos2D with sprites. Can someone point in the right direction the best way to animate these big images? (keep in mind that these images are dynamic and changes often so the sprites will have to be recreated on a server and fetched from the iPad to do the animation). Thanks
OpenGL only creates textures with dimensions at powers of 2. In the case of your images, that's 1024x1024, which is a meg of memory per image. Still, that shouldn't be a problem with the iPad.
First, investigate using Xcode's profiling tools to ensure the images aren't being repeatedly loaded into memory at each loop of the animation (likely by way of new objects that aren't sharing cached textures). That could solve your problem from the start.
Second, I recommend using Cocos2D if only for the easy handling of textures and caching. Toss the images into a CCAnimation, pop that into a CCRepeatForever, run it with a CCSequence. When you're done hit CCTextureCache to release unused textures.
Third, lower your animation framerate to 30 or less (if only for this animation). It may be the iPad, but you making a weather app. Not a video game.
Finally, downgrade the size of your image. Justify all you want, but a large radar animation will not sell your app. And just because a website might already be playing that animation beautifully, remember that a desktop has vastly more memory and power than any smart phone.
Try breaking the animation image into into smaller parts and animate those instead by treating each components as sprites. It would be best if you use primarily code (CoreGraphics) and draw your radar "by hand" instead of just using images as if they were animated GIFs.