Header image

Cocos2D Particle System Sources

March 21st, 2011 | Posted by lars in Cocos2D | iPhone | Particles | Source - (1 Comments)

Since I’m receiving questions about the particle system I used in my FluidToy 2 quite often lately, I thought I just release the sources here.

The particle system is based on a CCNode and works similar to the existing Cocos2D particle systems. The main difference is, that you can control the position and velocity of each particle. Please note that this system is not very optimized and lacks in flexibility since I just built it for FluidToy 2 and it was never meant to be more general. In other words: The code is a bit dirty! But feel free to play around with it, modify it and make use of it (and let me know what you’re making out of it).

There are two different systems: The SimpleParticleSystem, which draws points of any size or a point sprite using a texture. The second one is a LineParticleSystem, which will draw line particles. If you initialize the system with a size of 1000, you’ll have 500 lines, because a line consists out of 2 points (Wow, you never imagined that, did you? ;)). So if you loop through the particles, be sure to move only every second particle, the other one will follow with a small delay.

Download: Cocos2DSimpleParticleSystem

It works like every other CCNode:

particles = [SimpleParticleSystem node];
[particles initialize: 1000 width: size.width height: size.height];
[particles setTextureByString: @"particle_small.png"];
[self addChild: particles];
 
Loop through particles:
 
while(count < particles.particleCount)
{
   p = &particleAr[count];
   p->dir.x += CCRANDOM_MINUS1_1();
   p->dir.y += CCRANDOM_MINUS1_1();
   ++count;
   ...
}

Have fun!

ND2D – ParticleExplorer

March 16th, 2011 | Posted by lars in 3D | Molehill / Stage3D | ND2D | Particles - (0 Comments)

I just uploaded a ParticleExplorer I’m using to debug the ND2D particlesystem. It’s already fun to play with, but be careful it can freeze your browser ;)


(Note: The demo is broken with the latest Flashplayer 11 Release due to API changes)

I’d really like to push ND2D to github, but I’m struggling a bit with the current public PB3D release. There are some nasty bugs that make the renderings look ugly (Bilinear filtering is not working properly). I guess I have to wait for the next update :(

In this demo, you can see a GPU accelerated particle system I built for my upcoming ND2D engine. The particles are entirely processed on the GPU using pixelshaders. Flash does basically nothing :) There is still plenty of room for improvements, but the performance is already really good! I’ll post more details about the engine the next days…


(Note: The demo is broken with the latest Flashplayer 11 Release due to API changes)

Btw.: Who’s attending to the FITC Amsterdam next week? See you there ;)

F10 Astro Blackhole

September 30th, 2008 | Posted by lars in 3D | Actionscript | Experiments | Flash 10 | Particles | Source - (4 Comments)

The Flash 10 beta player is out for a while and I found a few minutes to try out the new native 3D effects. You can get quite nice and fast results out of the new API if you only want to display flat 2D planes in 3D-space:


(Space = fullscreen, Download source, Flash Player 10 needed)

War of the fireflies

January 21st, 2008 | Posted by lars in Experiments | Flash 9 | Particles | Simulations | Source - (6 Comments)

Derived from one of my older experiments: Three different populations of fireflies are fighting for their survival. If a firefly encounters an enemy fly, it tries to convert it to their tribe. The converted fly looses lifepoints and eventually dies during conversion. For the “collision logic”, I used a slightly modified version of Grant Skinners AS3 Proximitymanager. You can download the source and play around with it here (but don’t expect beautiful code ;)).


(Space = fullscreen, as usual)

Blackhole Simulator

January 11th, 2008 | Posted by lars in 3D | Experiments | Particles | Simulations - (0 Comments)

Another small test with my 3D Engine, I will post the sources for my 3D experiments within the next weeks, promised ;)


(Press any key to toggle fullscreen)

Touchscreen fun

January 3rd, 2008 | Posted by lars in Experiments | Flash 9 | Particles - (4 Comments)

There was this touchscreen in my office, so I had to play around with it and started one of my older experiments on it:

It’s evolving…

December 10th, 2007 | Posted by lars in Experiments | Flash 9 | Particles - (5 Comments)


more later ;)

AS3 Sounddetection

May 22nd, 2007 | Posted by lars in 3D | Experiments | Flash 9 | Particles | Sound - (3 Comments)

My first try with the new AS3 sound classes (SoundMixer.computeSpectrum). This test measures the average sound energy, triggers an event if the energy changes and emits a particle. The particles are 2D particles generated with my 3d Engine: Launch!

Fluid Dynamics

March 30th, 2007 | Posted by lars in Direct X | Experiments | Particles | Simulations - (4 Comments)

After spending a lot time playing around with Plasma Pong I tried to do fluids by myself. I found a Fluid Solver and had just to convert it to C# and add a few Direct X effects. Download not yet available. Watch movie!

Particle Test

March 30th, 2007 | Posted by lars in Direct X | Experiments | Particles - (0 Comments)

First steps with managed C# and DirectX. This is a direct conversion of my F9 Particles Experiment, but a lot faster and with a lot more particles at full screen resolution. Download not yet available. Watch movie!

Sand & Water

January 9th, 2007 | Posted by lars in Experiments | Flash 9 | Particles - (2 Comments)

Baggermatsch! Instructions: Press the button in the top left corner to change the drawing modes. Have fun playing in your sandpit. Launch!

F9 Particles

November 23rd, 2006 | Posted by lars in Experiments | Flash 9 | Particles | Source - (8 Comments)


Sources available here.

AS3 particle system. 5000 particles with random motion based on a noisemap (Press any key to view the map) Click to change to another random map. Launch!

Text Exploder

October 29th, 2006 | Posted by lars in Experiments | Flash 7/8 | Particles - (4 Comments)

Launch!

Magic Trails

January 4th, 2005 | Posted by lars in Experiments | Flash 7/8 | Particles - (1 Comments)

… and my version of a mouse follower, nothing special, just nice colors: Launch!