Cocos2d tunnel effect

I want to create a similar tunnel effect in COCOS2D (iOS). Can anyone suggest any pointers?

Ref image

ref video 1

ref video 2

So far, I have tried with several sprites of the shape of a ring with a decreasing scale and positioned the center at the same point, and also reduced Z for each smaller sprite.

With this, animating it with CCScaleTo and resizing it to 2.0 with the duration of the animation, but it still doesn't come close to the tunnel effect shown in the link.

Thank you myself

+4
source share
1 answer

I found a description of the implementation from the author of this effect:

“Of course, there was a lot of work to create the illusion of depth in the 2D plane. The principle is very simple: the circles begin in the middle of the screen with a scale of 0. Then the first circle of the tunnel starts to scale in proportion to the time elapsed (linear scaling does not work), and after a while the second the circle starts scaling, then the 3rd, 4th, etc. Then you proportionally decrease the alpha value for the circles (those that are in the far back have an alpha value lower than in front to create the illusion of blurring) , you determine the path which each circle should follow, moving its coordinates X and Y, then you place the spaceship in the middle of the screen.Inclining the device causes the tunnel to move left and right, up and down (but it seems that the spaceship is moving instead!) only circles exit the screen, they quickly disappear and return to their original position (to save memory, so I do not need to create new circles, but I reuse them). Sorry for my English, but I hope I explained the general idea :) "

+3
source

Source: https://habr.com/ru/post/1438846/


All Articles