gwenf Posted October 27, 2016 Share Posted October 27, 2016 I'm new to game development and I haven't been able to get any of the solutions from previous topics on this problem to work. I want the squares moving across the bottom of the screen to 'die' and run a function to increment a wastedItem number when they leave the screen. I have tried several methods to get this to work: 1. element.onOutOfBounds.add(this.killItem, this); //I can get the function to run, but it seems to run about 50-100 times even if I kill the object first and then run the function 2. I tried to add rectangles as tall as the screen to and use an overlap function: this.game.physics.arcade.overlap(element, this.wallRight, this.killItem, null, this); This function does not even run no matter where I seem to put it in the code. I would like to get option #1 to work and run the killItem function only once. I am probably doing something wrong because of a lack of understanding of Phaser. I would seriously appreciate any help with this. Here is my code: https://github.com/gwenf/phaser-object-throw (only one relevant main.js file, the code needs to be cleaned up a lot I know, but I am just trying to get this to work.) and here is a live demo: https://gwenf.github.io/phaser-object-throw/ Link to comment Share on other sites More sharing options...
samme Posted October 27, 2016 Share Posted October 27, 2016 Hi Gwen, try it this way: https://github.com/samme/phaser-object-throw/tree/outOfBounds gwenf 1 Link to comment Share on other sites More sharing options...
douglas Posted October 27, 2016 Share Posted October 27, 2016 funny game btw Link to comment Share on other sites More sharing options...
gwenf Posted October 27, 2016 Author Share Posted October 27, 2016 1 hour ago, douglas said: funny game btw Hey, I'm new at this Link to comment Share on other sites More sharing options...
gwenf Posted October 27, 2016 Author Share Posted October 27, 2016 1 hour ago, samme said: Hi Gwen, try it this way: https://github.com/samme/phaser-object-throw/tree/outOfBounds Could you explain to me what you were trying to do? It doesn't seem to work for me. Link to comment Share on other sites More sharing options...
gwenf Posted October 27, 2016 Author Share Posted October 27, 2016 Sorry, your solution worked perfectly, I was just on the wrong branch Thanks @samme douglas 1 Link to comment Share on other sites More sharing options...
Recommended Posts