AlexArroyoDuque Posted March 21, 2014 Share Posted March 21, 2014 Hi gamers! I have a group in which some coins are created with createMultiple.When I start the game the player collisions with unexpected group of coins ... The score of the player increases, therefore the collision occurs, but is not physically collide ... Some code: this.coinlGroup = this.game.add.group(); this.coinGroup.createMultiple(70, 'coin'); this.coinGroup.forEach(setupCoinGroup, this); Greetings! Link to comment Share on other sites More sharing options...
JP91 Posted March 21, 2014 Share Posted March 21, 2014 you need to add game.physics.enable (object, type physics) ???? Link to comment Share on other sites More sharing options...
AlexArroyoDuque Posted March 21, 2014 Author Share Posted March 21, 2014 mmm... This is my setup function: setupCoinGroup = function (coin, theGame) { theGame.game.physics.p2.enable(coin); coin.body.setCircle(16); coin.body.data.gravityScale = 0.25; coin.anchor.setTo(0.5, 0.5); coin.body.collides(theGame.playerCG); // ¿problem? coin.body.mass = 0.01; coin.alpha = 0.8;}; Link to comment Share on other sites More sharing options...
JP91 Posted March 21, 2014 Share Posted March 21, 2014 can make two collision groups. One for the player and other for the coins. Link to comment Share on other sites More sharing options...
AlexArroyoDuque Posted March 21, 2014 Author Share Posted March 21, 2014 Hi.I have some collision groups. And this is my player setup: player.body.collides([theGame.layerCG, theGame.coinCG]); player.body.createGroupCallback(theGame.CoinlCG, collisions.collisionPrice, theGame); collisionPrice kill the coin and upgrades the score. Link to comment Share on other sites More sharing options...
JP91 Posted March 21, 2014 Share Posted March 21, 2014 mmmm... player.body has been assigned a collision group. var playerGroup = game.physics.p2.createCollisionGroup(); player.body.setCollisionGroup(playerGroup); Link to comment Share on other sites More sharing options...
AlexArroyoDuque Posted March 22, 2014 Author Share Posted March 22, 2014 And this is my player: player = this.game.add.sprite(50, 50, 'player'); player.body.setCollisionGroup(theGame.playerCG); player.body.collides([theGame.coinCG]); player.body.createGroupCallback(theGame.coinCG, collisions.collisionPrice, theGame); Link to comment Share on other sites More sharing options...
AlexArroyoDuque Posted March 22, 2014 Author Share Posted March 22, 2014 In debug mode I see as the group of coins is generated at the position (0, 0) and fall on my player. Why? A greeting. Link to comment Share on other sites More sharing options...
rich Posted March 22, 2014 Share Posted March 22, 2014 Because in 2.0.0 it created the physics body regardless of the exists status when using createMultiple. This is fixed in 2.0.1 (currently in the dev branch, but will be released v. soon to master) Link to comment Share on other sites More sharing options...
Recommended Posts