BdR Posted July 19, 2018 Share Posted July 19, 2018 (edited) I'm working on a Phaser 3 game and all my sprites are in a spriteatlas. All the examples about particles and emitters I could find on the forum (like here and here) are using a single image-key as parameter for the particles. But is it also possible to use a spriteatlas as particles? This is my code below, but it doesn't seem to work. There are no errors but nothing appears on the screen. code removed And I have another questions actually: When I'm stuck with a Phaser3 problem like this, where is the best place to look up the info or documentation? So for example I don't know how to use `scene.add.particles`, where can I find the documentation about this constructor? I've looked here, but AFAIK the info I'm looking for is not there. I found the v2 documentation very clear and legible, and I'm struggling a bit with this new v3 documentation. Is it there or am I over looking in the wrong place? Edited July 20, 2018 by BdR removed the code, because it was incorrect anyway Link to comment Share on other sites More sharing options...
ol-web Posted July 19, 2018 Share Posted July 19, 2018 I've never touched atlases so I can't tell but your example does work on my spritesheets. Maybe you could set the frame to an integer, at least that's how I use it with spritesheets. As for finding stuff in the documentation I usually just search for Phaser.Scene constructor as most of the time the this keyword refers to the scene. And from there I just go to Scene's method add() and that points me to GameObjectFactory and that points me to particles() method. It's just javascript classes everywhere. https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.GameObjectFactory.html#particles__anchor BdR 1 Link to comment Share on other sites More sharing options...
BdR Posted July 19, 2018 Author Share Posted July 19, 2018 I've found an example with frames and the code below works for me btw somehow the "blendMode: ADD" seem to sometimes make the particles invisible, for example it does work in this example but it doesn't in this example. preload: function () { // sprites this.load.atlas('sprites', 'img/spritearray.png', 'img/spritearray.json'); }, // bomb explosion particles var expl = this.add.particles('sprites'); this.bombexpl = expl.createEmitter({ frame: [ 'bombexpl1', 'bombexpl2', 'bombexpl3' ], // random frames quantity: 10, scale: { start: 1.0, end: 0 }, // particles shrink speed: { min: -1000, max: 1000 }, // speed is variable lifespan: 800, on: false }); // set emitter to position and explode this.bombexpl.setPosition(100, 100); this.bombexpl.explode(); So you can start the emitter with .explode() to release a "quantity" amount of particles at once OR you can do .start() and it will continuously emit "quantity" amount of particles for every "frequency" milliseconds. But I have another question, is it possible to use .start() for a specific amount of times? So emit X particles every Y ms, but stop after let's say 5 times. So can you make the emitter do it 5 times and then automatically stop? Link to comment Share on other sites More sharing options...
Recommended Posts