kelvinblade Posted April 13, 2015 Share Posted April 13, 2015 I am trying to make coins explode out of a monster when it is killed. the explode would be similar to this example: http://phaser.io/examples/v2/particles/diamond-burstI also want the coins to be clicked individually similar to this example:http://phaser.io/examples/v2/groups/call-all-inputI am confused as to how to incorporate the two above examples together. Is emitting particles the way to go? I am also confused as to how to set each coin to have a different value depending on the monster.Any help is appreciated. Link to comment Share on other sites More sharing options...
valueerror Posted April 13, 2015 Share Posted April 13, 2015 you could create a pool of sprites and only reset them when needed with a custom function that also sets some other variables.. coins = game.add.group(); // add a new group for fireballs coins.createMultiple(500, 'coin', 0, false); // create plenty of them hidden and out of the game worldon explode: function explode() { var coin = coins.getFirstExists(false); // get the first created fireball that no exists atm if (coin){ coin.exists = true; // come to existance ! coin.lifespan=2500; // remove the fireball after 2500 milliseconds - back to non-existance coin.reset(monster.x, monster.y); game.physics.p2.enable(coin); coin.body.moveUp(800); coin.body.setCircle(10); } } Link to comment Share on other sites More sharing options...
kelvinblade Posted April 14, 2015 Author Share Posted April 14, 2015 thanks! ok my game is a tap based game. after a few monsters die and the coins drop and some of them overlap, how can i make it so that one tap on an area picks them all up? i currently have them as a group and i do : this.coins.setAll('inputEnabled', true);this.coins.callAll('events.onInputDown.add', 'events.onInputDown', this.removeCoin); Link to comment Share on other sites More sharing options...
Recommended Posts