user1234 Posted May 12, 2014 Share Posted May 12, 2014 I am using a portion of the tank games demo that creats a group in a different way I have this at the top of my codevar EnemyTank = function (game) { var x = game.world.randomX; var y = game.world.randomY; this.tank = game.add.sprite(x, y, 'enemy'); this.tank.anchor.set(0.5); game.physics.enable(this.tank, Phaser.Physics.ARCADE); game.physics.arcade.collide(this.tank,cat); this.tank.body.immovable = false; this.tank.body.collideWorldBounds = true; this.tank.body.bounce.setTo(1, 1); this.tank.angle = game.rnd.angle(); game.physics.arcade.velocityFromRotation(this.tank.rotation, 100, this.tank.body.velocity); game.physics.arcade.collide(this.tank);};'this is in the create enemies = []; enemiesTotal = 20; enemiesAlive = 20; for (var i = 0; i < enemiesTotal; i++) { enemies.push(new EnemyTank(this.game)); }And this is in the updatethis.game.physics.arcade.collide(enemies);The objects are not bouncing off of each other. Any suggestions? Link to comment Share on other sites More sharing options...
Tuan Posted June 1, 2014 Share Posted June 1, 2014 I've the same question Please help us! Link to comment Share on other sites More sharing options...
DerDree Posted June 2, 2014 Share Posted June 2, 2014 I would also like to see a solution for this. In other game frameworks each object can have a type and collision can then be defined by type. So its easy to have a group of objects colliding with each other and maybe another group of objects. I dont know if thats possible with phaser. Link to comment Share on other sites More sharing options...
benjamin Posted June 2, 2014 Share Posted June 2, 2014 Just my guess here. collide is meant to be called each time you want to test for collision and trigger reactions. (e.g on every update). Secondly collide expects the two objects that you want to test for collision. so remove your collision stuff from the Enemytank object, and place this in your update callback. (what is 'cat'?)game.physics.arcade.collide(this.tank,cat);and thisthis.game.physics.arcade.collide(this.tank, enemies);You may also want to add a callback as a third parameter if you want to be notified of the collision. Link to comment Share on other sites More sharing options...
Recommended Posts