Cocos Creator API

1.0.0

Cocos Creator is a highly customizable game development tool that utilizes the power of cocos2d-x.

ParticleSystem

Module: cc

Particle System base class.
Attributes of a Particle System:

  • emmision rate of the particles
  • Gravity Mode (Mode A):
  • gravity
  • direction
  • speed +- variance
  • tangential acceleration +- variance
  • radial acceleration +- variance
  • Radius Mode (Mode B):
  • startRadius +- variance
  • endRadius +- variance
  • rotate +- variance
  • Properties common to all modes:
  • life +- life variance
  • start spin +- variance
  • end spin +- variance
  • start size +- variance
  • end size +- variance
  • start color +- variance
  • end color +- variance
  • life +- variance
  • blending function
  • texture

    cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).
    'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d,
    cocos2d uses a another approach, but the results are almost identical.
    cocos2d supports all the variables used by Particle Designer plus a bit more:
  • spinning particles (supported when using ParticleSystem)
  • tangential acceleration (Gravity mode)
  • radial acceleration (Gravity mode)
  • radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only)
    It is possible to customize any of the above mentioned properties in runtime. Example:

examples:

emitter.radialAccel = 15;
emitter.startSpin = 0;

Properties

preview Boolean

Play particle in edit mode.

custom Boolean

If set custom to true, then use custom properties insteadof read particle file.

file string

The plist file.

texture Texture2D

.

particleCount Number

Current quantity of particles that are being simulated.

srcBlendFactor BlendFactor

Specify the source Blend Factor.

dstBlendFactor BlendFactor

Specify the destination Blend Factor.

playOnLoad Boolean

If set to true, the particle system will automatically start playing on onLoad.

autoRemoveOnFinish Boolean

Indicate whether the owner node will be auto-removed when it has no particles left.

active Boolean readOnly

Indicate whether the particle system is activated.

totalParticles Number

Maximum particles of the system.

duration Number

How many seconds the emitter wil run. -1 means 'forever'.

emissionRate Number

Emission rate of the particles.

life Number

Life of each particle setter.

lifeVar Number

Variation of life.

startColor Color

Start color of each particle.

startColorVar Color

Variation of the start color.

endColor Color

Ending color of each particle.

endColorVar Color

Variation of the end color.

angle Number

Angle of each particle setter.

angleVar Number

Variation of angle of each particle setter.

startSize Number

Start size in pixels of each particle.

startSizeVar Number

Variation of start size in pixels.

endSize Number

End size in pixels of each particle.

endSizeVar Number

Variation of end size in pixels.

startSpin Number

Start angle of each particle.

startSpinVar Number

Variation of start angle.

endSpin Number

End angle of each particle.

endSpinVar Number

Variation of end angle.

sourcePos Vec2

Source position of the emitter.

posVar Vec2

Variation of source position.

positionType ParticleSystem.PositionType

Particles movement type.

emitterMode ParticleSystem.EmitterMode

Particles emitter modes.

gravity Vec2

Gravity of the emitter.

speed Number

Speed of the emitter.

speedVar Number

Variation of the speed.

tangentialAccel Number

Tangential acceleration of each particle. Only available in 'Gravity' mode.

tangentialAccelVar Number

Variation of the tangential acceleration.

radialAccel Number

Acceleration of each particle. Only available in 'Gravity' mode.

radialAccelVar Number

Variation of the radial acceleration.

rotationIsDir Boolean

Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode.

startRadius Number

Starting radius of the particles. Only available in 'Radius' mode.

startRadiusVar Number

Variation of the starting radius.

endRadius Number

Ending radius of the particles. Only available in 'Radius' mode.

endRadiusVar Number

Variation of the ending radius.

rotatePerS Number

Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.

rotatePerSVar Number

Variation of the degress to rotate a particle around the source pos per second.

DURATION_INFINITY Number readOnly static

The Particle emitter lives forever.

START_SIZE_EQUAL_TO_END_SIZE Number readOnly static

The starting size of the particle is equal to the ending size.

START_RADIUS_EQUAL_TO_END_RADIUS Number readOnly static

The starting radius of the particle is equal to the ending radius.

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

Methods

addParticle ( ) Boolean

Add a particle to the emitter.

returns:

type: Boolean

stopSystem ( )

Stop emitting particles. Running particles will continue to run until they die.

examples:

// stop particle system.
myParticleSystem.stopSystem();

resetSystem ( )

Kill all living particles.

examples:

// play particle system.
myParticleSystem.resetSystem();

isFull ( ) Boolean

Whether or not the system is full.

returns:

type: Boolean

setDisplayFrame
(
  • spriteFrame
)

Sets a new CCSpriteFrame as particle.
WARNING: this method is experimental. Use setTextureWithRect instead.

name type description
spriteFrame SpriteFrame

setTextureWithRect
(
  • texture
  • rect
)

Sets a new texture with a rect. The rect is in texture position and size.

name type description
texture Texture2D
rect Rect

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index