Phempt Posted October 24, 2014 Share Posted October 24, 2014 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"); Quote Link to comment Share on other sites More sharing options...
Phempt Posted October 24, 2014 Author Share Posted October 24, 2014 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. Quote Link to comment Share on other sites More sharing options...
enpu Posted October 24, 2014 Share Posted October 24, 2014 Hmm, can't see anything wrong with your code, except small typo in this line: this.startEmitter.position.set(x, y); should be: this.starEmitter.position.set(x, y); Quote Link to comment Share on other sites More sharing options...
Phempt Posted October 24, 2014 Author Share Posted October 24, 2014 unfortunately that wasn't the error, is there any way to debug an emitter? Quote Link to comment Share on other sites More sharing options...
Phempt Posted October 24, 2014 Author Share Posted October 24, 2014 this is the emitter object: it seems ok.. I really don't know what's wrong... Quote Link to comment Share on other sites More sharing options...
enpu Posted October 24, 2014 Share Posted October 24, 2014 Can you show your full code? Quote Link to comment Share on other sites More sharing options...
Stephan Posted October 24, 2014 Share Posted October 24, 2014 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(); } }); }); Quote Link to comment Share on other sites More sharing options...
enpu Posted October 24, 2014 Share Posted October 24, 2014 All emitter times (duration, life, rate) are changed from seconds into milliseconds in Panda 1.9 So lineemitter.duration = 2; should be emitter.duration = 2000; Quote Link to comment Share on other sites More sharing options...
Phempt Posted October 24, 2014 Author Share Posted October 24, 2014 I sent you the package (sorry it's 1MB cause I included all). Thank you Quote Link to comment Share on other sites More sharing options...
Stephan Posted October 24, 2014 Share Posted October 24, 2014 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); } });}); Quote Link to comment Share on other sites More sharing options...
Phempt Posted October 24, 2014 Author Share Posted October 24, 2014 I don't know why, but removing this:this.starEmitter.rate = 0;it works! Quote Link to comment Share on other sites More sharing options...
Stephan Posted October 24, 2014 Share Posted October 24, 2014 Yes, that's the line that caused the problem. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.