rickydamta Posted November 11, 2015 Share Posted November 11, 2015 Hi!I am making a tower defense game.I need to check if a the "enemy" sprite is on the stage,how do I do that?Thanks Link to comment Share on other sites More sharing options...
ekeimaja Posted November 11, 2015 Share Posted November 11, 2015 Easiest way to do that is to tag that specific stage and then make collisioncheck with overlap. Link to comment Share on other sites More sharing options...
rickydamta Posted November 11, 2015 Author Share Posted November 11, 2015 Ok thanks,i will try that! But I'm searching for a line of code to do that Link to comment Share on other sites More sharing options...
Batzi Posted November 11, 2015 Share Posted November 11, 2015 Ok thanks,i will try that! But I'm searching for a line of code to do thatgame.physics.arcade.overlap(enemy, stage, callBackFunction, null, this);function callBackFunction{ console.log('It is overlapping!');} Link to comment Share on other sites More sharing options...
BrunoHautenfaust Posted November 11, 2015 Share Posted November 11, 2015 the inWorld property is what you're looking for.if (enemy.inWorld) {// Do stuff}Here's an example:http://phaser.io/sandbox/edit/YopWUyzI Just move the player to the left until he's out of the screen.You'll need to open the console in Dev Tools to see the result. chongdashu 1 Link to comment Share on other sites More sharing options...
rickydamta Posted November 11, 2015 Author Share Posted November 11, 2015 Thanks for answering Link to comment Share on other sites More sharing options...
Recommended Posts