Jump to content

Emitter, no error shown but doesn't work


Phempt
 Share

Recommended Posts

Hello guys, I'm trying to spawn an emitter on sprite's click.

 

I made a custom class because I can call the emitter from other 2 or 3 custom classes:

game.createClass('emitterSpawn', {    init: function(x,y){            console.log(x);            console.log(y);            var emitter = new game.Emitter();	        emitter.container = game.scene.containerEnemies;	        emitter.textures.push('emitter/star.png');	        emitter.position.set(x, y);	        emitter.duration = 2;	        game.scene.addEmitter(emitter);	        console.log('emitter spawned');    }});

In an other custom class, there is the touch event code:

this.enemy.touchstart = this.enemy.click = function(){            //console.log('touched');            var posXEmitter = this.position.x;            var posYEmitter = this.position.y;            var emitterVar = new game.emitterSpawn(posXEmitter,posYEmitter);.......

The enemies container is defined in Main.js and it works (enemies are correctly shown):

this.containerEnemies = new game.Container();this.containerEnemies.addTo(this.stage);

This is the result:

Panda.js 1.9.0 core.js:334Pixi.js 1.6.1 core.js:335Canvas renderer 320x480 core.js:336Web Audio engine core.js:337Bird Catching 1.0.0 core.js:33970.39999999999996 enemies.js:592.71000000000001 enemies.js:6emitter spawned 

but I can't see the emitter, any suggestion?

 

 

edit:

of course the star.png sprite is declared into assets.js:

game.addAsset("emitter/star.png");
Link to comment
Share on other sites

I also tried to change my emitter custom classes with:

game.createClass('emitterSpawn', {    init: function(x,y){            console.log(x);            console.log(y);            this.starEmitter = new game.Emitter();            this.starEmitter.container = game.scene.containerEnemies;            this.starEmitter.textures.push('emitter/star.png');            this.starEmitter.rate = 0;            this.startEmitter.position.set(x, y);            this.starEmitter.speed = 80;            this.starEmitter.speedVar = 20;            this.starEmitter.life = 1500;            this.starEmitter.rotate = 5;            this.starEmitter.rotateVar = 2;            this.starEmitter.startScale = 2;            this.starEmitter.endScale = 0;            this.starEmitter.endAlpha = 1;        game.scene.addEmitter(this.starEmitter);    }});

but always the same problem, I don't see the stars, without errors.

Link to comment
Share on other sites

I tried the following example which works fine in panda 1.8 but NOT in panda 1.9:

game.module(	'game.main').require(	'plugins.physicsextend').body(function() {		game.addAsset('bubble.png');	game.addAsset('panda.png'); 	game.createClass('emitterSpawn', {	    init: function(x,y){	            console.log(x);	            console.log(y);	            var emitter = new game.Emitter();		        emitter.container = game.scene.containerEnemies;		        emitter.textures.push('panda.png');		        emitter.position.set(x, y);		        emitter.duration = 2;		        game.scene.addEmitter(emitter);		        console.log('emitter spawned');	    }		});				game.createScene('Main', {		backgroundColor: 0xe1d4a7,				init: function() {			this.containerEnemies = new game.Container();			this.containerEnemies.addTo(this.stage);                        var emitterSpawn = new game.emitterSpawn();    					} 	}); });
Link to comment
Share on other sites

The following code works inversion 1.9. I marked a few changes:

game.module(	'game.main').body(function() {	game.addAsset('emitter/star.png'); game.createClass('emitterSpawn', {    init: function(x,y){        console.log(x);        console.log(y);        this.starEmitter = new game.Emitter();        this.starEmitter.container = game.scene.containerEnemies;        this.starEmitter.textures.push('emitter/star.png');                    //Removed line:        //this.starEmitter.rate = 0;   //This causes a problem!!!                    //Changed startEmitter => starEmitter        this.starEmitter.position.set(x, y);                    this.starEmitter.speed = 80;        this.starEmitter.speedVar = 20;        this.starEmitter.life = 1500;        this.starEmitter.rotate = 5;        this.starEmitter.rotateVar = 2;        this.starEmitter.startScale = 2;        this.starEmitter.endScale = 0;        this.starEmitter.endAlpha = 1;        game.scene.addEmitter(this.starEmitter);    }});		game.createScene('Main', {		backgroundColor: 0xe1d4a7,				init: function() {			this.containerEnemies = new game.Container();			this.containerEnemies.addTo(this.stage); 				 				 		var emitterSpawn = new game.emitterSpawn(200,300);	  		}	});});
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...