Hi All,
How can we animate waterfall using cocos2d.
I saw particle Demo sample code i could not find it,
Any suggestion how to do that will be a great help.
Thanks in Advance,
BP
A fast, easy to use, free, and community supported 2D game engine
Hi All,
How can we animate waterfall using cocos2d.
I saw particle Demo sample code i could not find it,
Any suggestion how to do that will be a great help.
Thanks in Advance,
BP
Bhanu:
I'm not exactly sure what you are trying to achieve, but Cocos2d does includes multiple 'test' build targets, one of which is called ParticleTest. The source code is included, and is fairly simple.
-CJL
You are going to have a hell of a time trying to animate water on the iPhone, let alone a waterfall which should be nice and beautiful. I've never taken any fluid dynamics but it isn't easy to simulate especially with very limited CPU power. Now, the way to cheat and simulate water is to have a lot of very small particles (blue obviously) all set to really low friction. It will probably lag though...
I've seen some damn good fluid dynamics though in a game called aqua forest. It's great actually but the water is done using an engine known as octave engine which is a very powerful engine. Simulating water using particles is usually okay for smaller projects though but certainly very hard to achieve on the iPhone.
My suggestion is to get a very nice animation sequence. That way it is FAR less cpu intensive and you have the freedom to make it look as real as you want since it's only graphics. If you want the waterfall to interact with an object then you could hard code some more animations to be played...it's really the best way I can think of doing it efficiently. But if you want a dynamic waterfall, look up the octave engine, but I doubt it'd be easy to use...I'm not even sure it's free.
Sorry to revive a thread that's two months old, but I thought this might be of help to somebody in the future. Obviously the best solution to this is a simple animation. It's much less resource intensive and it will look better. However, if you're like me and have very little knowledge of animation techniques and no artist to work with, you CAN make a passable waterfall with a particle effect. Keep in mind that when I say passable, I mean exactly that... it's not very pretty, but it gets the job done in a pinch. I'm likely going to try to change this out for an animation once I can figure out how to get the desired effect. In the meantime, though, perhaps someone will find this helpful.
@implementation ParticleWaterfall
- (id) init
{
return [self initWithTotalParticles:100];
}
- (id) initWithTotalParticles: (int) p
{
if(self != [super initWithTotalParticles: p])
return nil;
// angle
angle = 270;
angleVar = 12;
// emitter position
self.position = ccp(160, 60);
posVar = ccp(16, 4);
// life of particles
life = 2;
lifeVar = 0.25f;
// speed of particles
speed = 100;
speedVar = 20;
gravity.y = -5;
// size of particles
startSize = 34.0f;
endSize = 70.0f;
// color of particles
startColor.r = 0.7f;
startColor.g = 0.7f;
startColor.b = 1.0f;
startColor.a = 0.6f;
startColorVar.r = 0.0f;
startColorVar.g = 0.0f;
startColorVar.b = 0.0f;
startColorVar.a = 0.0f;
endColor.r = 0.5f;
endColor.g = 0.5f;
endColor.b = 0.5f;
endColor.a = 0.0f;
endColorVar.r = 0.0f;
endColorVar.g = 0.0f;
endColorVar.b = 0.0f;
endColorVar.a = 0.0f;
// additive
blendAdditive = NO;
return self;
}
@end
Just define ParticleWaterfall as a subclass of ParticleFire and you're good to go. Tweak the parameters to your liking.
You must log in to post.