Closed thewayur closed 2 years ago
Setting any of the particle properties on the Emitter will apply them to all particles spawned in the future. PathParticle may help you do zigzag motions. You can always make a new class that extends Particle and does anything specific that you need, then set your emitter's particleConstructor
property to your subclass's constructor.
@andrewstart i tried but i dont know where to place code. To use this class, the particle config must have a "path" string in the "extraData" parameter.
my config json code does not have extraData. could you please write a shorted code for me? thanks!
my code: ` var emitter = new PIXI.particles.Emitter(
// The PIXI.Container to put the emitter in
// if using blend modes, it's important to put this
// on top of a bitmap, and not use the root stage Container
container3,
// The collection of particle images to use
[PIXI.Texture.from('h.png')],
// Emitter configuration, edit this to change the look
// of the emitter
{
"alpha": {
"start": 1,
"end": 0.1
},
"scale": {
"start": 0.25,
"end": 0.5,
"minimumScaleMultiplier": 0.5
},
"color": {
"start": "ffffff",
"end": "ffffff"
},
"speed": {
"start": 200,
"end": 200
},
"startRotation": {
"min": 270,
"max": 270
},
"rotationSpeed": {
"min": 30,
"max": 40
},
"lifetime": {
"min": 3.5,
"max": 4
},
"blendMode": "normal",
"frequency": 1,
"emitterLifetime": 0,
"maxParticles": 40,
"pos": {
"x": 0,
"y": 0
},
"addAtBack": false,
"spawnType": "rect",
"spawnRect": {
"x": -450,
"y": 900,
"w": 900,
"h": 0
}
}
);`
Look at more of the examples, like the ones that use the path particles.
thanks, i got it working, for future people(including me)
in json config
` { ... "spawnType": "rect", "spawnRect": { "x": 0, "y": 300, "w": 0, "h": 0 }, "extraData": { *"path": "sin(x/10)20" }** }
`
and in emitter variable/instance = ` var emitter = new PIXI.particles.Emitter( ....) emitter.particleConstructor = PIXI.particles.PathParticle;
`
i am new to pixi, gsap and your library and specially in canvas system. and somewhat understand the properties and methods.
so please guide me how to change the particles direction at runtime like spawning at different locations and changing there speed motions like zigzag. well i can write the code or random positions and intervals. but i dont know how to pass these parameters in ur library, i m able to achieve those in gsap+pixi.
so how to pass position, speed and other parameters for containers specially how to take control over individual particle (iff possible). i am using ur doc sample json config, thank you!