ibb671 Posted April 25, 2016 Share Posted April 25, 2016 Hello I was wondering what would be causing this error this is the section of code that i think its causing this error. Sorry i'm still learning about javascript and phaser in general. Thanks in advanced for you guys again for your help. if(element.frame==6/){ enemy++; if(enemy>5 && element.frame==6){ this.mothersDayItems.forEachAlive(function(element2){ if(element2.frame==6){ var enemyTween = me.game.add.tween(enemySprite).to({ alpha:0, },2000,Phaser.Easing.Linear.Out,true); me.enemyTween.onComplete(function(){ element2.kill(); element2.alpha=1; }); } enemy=0; },me); //element.kill(); } /*this.particleBurst(element.x,element.y-20);*/ } Link to comment Share on other sites More sharing options...
in mono Posted April 25, 2016 Share Posted April 25, 2016 Don't know what "me" is, but I'm pretty sure that "me" doesn't know about any tween. Just from that example, I'd try this: enemyTween.onComplete.add(function() { element2.kill(); element2.alpha = 1; }, this); since enemyTween is just a local variable. Note that you can't assign the function to onComplete, you must go with onComplete.add(). Usually you must also add a callback context (the "this" on the last line). If you won't need the tween later, you can go straight like this without assigning it to a variable: me.game.add.tween(enemySprite) .to({alpha: 0}, 2000, Phaser.Easing.Linear.Out, true) .onComplete .add(function(){ element2.kill(); element2.alpha = 1; }, this); Link to comment Share on other sites More sharing options...
ibb671 Posted April 25, 2016 Author Share Posted April 25, 2016 Thank you so much for your help . I'm learning phaser from different tutorials online and i got the "me" from one of josh morony's tutorial https://www.joshmorony.com/ hehe. So im still learning the ropes and thank you again my friend. Link to comment Share on other sites More sharing options...
Recommended Posts