0
votes

I'm trying to think of a method to 'sort of programmatically' animate sprites in a game. The purpose of this is to avoid creating ~20-50 frames of each sprite (very time consuming), then running a loop to sequence the frames, thus producing the desired animation. Below is one example of a sprite I would like to animate. The desired animation should give 'waves' to the image, originating in the center and expanding outward. This will make the water color look alive, or as if it's still wet and shimmering. I'm using Cocos2D so each sprite has these methods available already: move, rotate, scale. My initial thought is to use Cocos2D's particle system to try and create this effect, but I worry about the efficiency of running the system for perhaps 50 or so sprites. Is there a better way?

'play game button'

2

2 Answers

2
votes

What you want to achieve is probably best done with custom vertex/fragment shader. Unfortunately not many examples floating around, so you have to look. But to get you started, look here, there might be one there close to your desires. Beware, shaders can be tricky and are hardly the kind of 'drop from open source repository' to your codebase type of software. Some tweaking required, your mileage will vary.

for a crash 'intro' on openGL , shaders and stuff, if you are inclined, this blog was very helpful to me. Follow the links.

0
votes

A particle system would probably be pretty rough on performance if you have a large number of them.

Most people use pre-created water tiles that animate. So each tile would have 4 frame of animation or whatever, and on creation, you would set each one to animate through those 4 frames repeatedly.

You may also want to look into the CCRipple3D action.