Cocos2D animation - cut scene into pieces - animation

I found this animation http://youtube.com/watch?v=wt6gsIcNBOA (have a look at 1:46).
I can not find anything how this animation was accomplished. Basically it should look like the scene is cut into 3 different parts.
Any idea how to make a similar animation ?

its a "simple" CCTransitionSplitRows animation
CCTransitionSplitRows *transition = [CCTransitionSplitRows transitionWithDuration:1 scene:scene];
[[CCDirector sharedDirector] replaceScene:transition];
there are more of such fancy transition in cocos2d
see
http://www.pawapps.com/2011/07/30/tutorial-transitions-in-cocos2d/ for example

Related

How to animate horizontal bar with right cap, by UIView animation in iPhone

I got wiered but unsurprising animation from call UIView animation, I don't know if it works the same by using CALayer animation. I guess it is.
please see this picture: what I want is to animate a horizontal bar growing horizontally, what I do is:
Subclass a UIView, called UIViewBar, and in its drawRect:rect method, I draw the shape of rectangle and a right cap, it's done by
CGContextMoveToPoint A
CGcontextAddLineToPoint B
CGContextAddArcToPoint D
CGContextAddLineToPoint C
//then close the path and fill the context
Then I call this UIViewBar (initWithFrame:rect) in my UIViewController, and the shape is what I want, looks fine. BUT when I perform [UIView animation] say from original rect to rectGrew it does not perform nicely. Instead, it perform as the picture says.
Well, after thinking, it's not totally unreasonable because when the UIView horizontally stretches itself, it does not know the cap will not be changed. So is there another way to do this?
Actually, I'm very new to drawing, graphic, and animation. What I know is that (if wrong please kindly correct me):
If I want to "draw something", I should override the UIView's drawRect method, and this is done by initing the UIView, should not or better not to be called outside. Say I drew a rectangle in a UIView by CGContextFillRect.....
But what if I want to animate this rectangle? I cannot make animation based on Quartz2D, but from UIView animation or CALayer(deeper tech), so What I have to do is to make the rectangle itself as a seperate UIViewRect seperately, so I can call the [UIViewRect animation] method, AM I RIGHT ON THIS
If so, I have to make every rectangle that I want to animate to be UIView respectively. Doesn't it affect performance? Or it is just the way apple prefers to do ?
Any suggestion will be much helpful, GREAT thanks.
Wow, it's the first time that no answer posted at all! TO answer my question: it requires to consider animate custom property of CALayer. The custom property is the AB width (the width without cap width, that should work). If someone wants detailed code. Please google custom property animate in CALayer.

Combine sprite animation with path movement with CALayer

In Monotouch, I need to create a basic animation of an image moving along a path while animating it's image content with a sprite sheet or replacing the content CGImage, everything i try i can't combine both animations. I tried subclassing the CALayer and animate custom properties or combine animations in group nothing seems to work. What's the best way to produce this kind of animation?
To get a smooth animation, you want to think of what CAlayers represent: they are a handle to a texture that live in the GPU space. To get smooth animation you can control a few of their properties, but arbitrary changes like rendering the data again wont work fine.
What you should do is put all of your images in the sprite sheet, and then animate the ContentsRect property of the CALayer.

UIScrollview setContentOffset and animation

I want to setContentOffset with different animation transition.
Now I use:
[UIScrollView animateWithDuration:speed animations:^ {
[scrollView setContentOffset:offset];
}];
Can you help me, How I achieve animation during set offset.
I am not quite sure, I understand what you are looking for. However, in the case you are looking for a UIScrollView class whose contentOffset is animated with a non-linear timing function you might take a like at my MOScrollView. I use a CADisplayLink to animate the contentOffset. Though, please note that it might not work perfectly as I did not yet use this class in production.

get CATransform3D from Projection and ModelView matrices

How to get CATransform3D from Projection and ModelView matrices
I have browse this question before,the url;but it wasn't absolutely precise; I want to know why it’s not precise;
I find that the rotate by x--axis and y--axis is opposite(I can't post image);the Trapezoidal(when rotate the calayer , it's like a Trapezoidal) is opposite,dose calayer rotate is not like opengl?but it's right when rotate by z--axis.
I want get the Angle and then rotate it twice opposite;how to get Angle by the opengl matrices?
I want play movie by QCAR; I can get opengl matrices,and I want to use UIView to playe movie and other(Familiar with the UIView),and make UIview like Texture.
I just post a example on QCAR forum, you can check the detail here
The idea is simple.
1.I don't use avassetreader to read the video pixel, instead I use AVPlayer and AVPlayerLayer which can play remote video file.
2.I need to convert opengl modelview matrix to CATransform3D so the AVPlayerLayer will attach on the trackable image.Thanks for Hammer on stackoverflow, he shared an example about how to make this.
3.I tried to render camera background use opengl and AVPlayerLayer at same time, but the performace is not good enough, so I use another calayer to render the camera background. There is a bug in 1.5.8 when getting camera frame, thank for andersfrank the problem was solved here.
I put my code on pastebin:
http://pastebin.com/kmeVZ7jy
There are still some problem need to solve, but I think this is a right approach.
PS. For question 3 in my original post, you can fix it by set
cameraLayer.contentsGravity = kCAGravityResizeAspectFill;
This will fix the problem that the aspect ratio of the camera image is different with the iphone screen's.
Update
All the problem are solved, please check my original post on vuforia and pastebin.

Replacing image in sprite - cocos2d game development of iPhone

I want to change the sprite image.
Say for example:
mainSprite=[Sprite spriteWithFile:#"redFile.png"];
[self addChild:mainSprite];
Here, Sprite is already added to a layer. I have mainSprite (pointer) which can access it.
If I change
[mainSprite setOpacity:150];
it works perfectly. But here I want to change the sprite image instead of opacity.
But I don't know how.
#sagar:
In cocos2d 0.99.x I use
[sprite setTexture:[[CCTextureCache sharedTextureCache] addImage:#"sprite.png"]];
It works. The next question is, how can I get back to my previous sprite? Thanks
Ok. Damn Simple.
I find it by R & D.
Texture2D *x=[[Texture2D alloc]initWithImage:[UIImage imageNamed:#"box-purple-dark.png"]];
[mainSprite setTexture:x];
Replace image in sprite :
[sprite setTexture:[[CCTextureCache sharedTextureCache] addImage:#"image.png"]];
Replace image in sprite :
CCTexture2D *tex1 = [[CCTextureCache sharedTextureCache] addImage:#"new-image.png"];
[mainSprite setTexture:tex1];

Resources