Search the Community
Showing results for tags 'getFirstExists'.
-
Hi, I'm new (another one) with phaser. I did a test game without problems (or almost) but now I'm doing a game that throws objects ad infinitum. In order to do this I'm sprite recycling. I have a group of sprites with outOfBoundsKill and checkWorldBounds set to true. And then when it's time to throw an object I fetch the first that does not exists. Here's my code: // Coinsthis.coins = this.add.group();this.coins.enableBody = true;this.coins.physicsBodyType = Phaser.Physics.ARCADE;this.coins.createMultiple(4, 'coin');this.coins.setAll('outOfBoundKill', true);this.coins.setAll('checkWorldBounds', true);And this is the function to throw coins (from the bottom of the world to the top): throwSomething() { this.coin = this.coins.getFirstExists(false); this.coin.reset(this.throwers_x[droperNumber], this.throwers_y); this.coin.animations.add('spin', [0, 1, 2, 3, 4, 5, 6, 7], 10, true); this.coin.play('spin'); this.coin.body.gravity.y = -300; this.dropingTimer = this.game.time.now + 2000;}The moment all coins are created there's no coins with exists set to false. It should be, since outOfBoundKill is on. The animation add and play, and the body.gravity were in the create function at the beginning, but I changed to test things. Any ideas?
- 8 replies
-
- sprite recycling
- null
-
(and 2 more)
Tagged with: