andiua Posted February 15, 2019 Share Posted February 15, 2019 Hello. I`ve just start to learned game dev with Phaser. Read a lot topics here and saw documentation, but I don`t know what to do I`m trying to colliding between bombs and the ground. Ground is a group creating from JSON function update() { bombFires(); game.physics.arcade.collide(bombFire, floors); } function bombFires(){ if(bombCount > 0 && spaceKey.downDuration(1)){ bombCount--; bombText.setText('Bomb ' + bombCount + ' x'); bombFire = game.add.sprite(cyclist.body.x + 20, cyclist.body.y + 70, 'bombFire'); bombFire.anchor.set(0.5); bombFire.animations.add('bombFire'); bombFire.animations.play('bombFire',20, true); game.physics.enable(bombFire, Phaser.Physics.ARCADE); bombFire.body.velocity.set(320, 0); bombFire.body.gravity.y = gravitation; } } in this case one bomb always on floor but when I pressed again spasekey old bomb fall and new is on the floor. Also I`ve tried to do this with group, but result is the same function bombFires(){ if(bombCount > 0 && spaceKey.downDuration(1)){ bombFire = game.add.group(); bombFire.enableBody = true; game.physics.enable(bombFire, Phaser.Physics.ARCADE); bombFire.create(cyclist.body.x + 20, cyclist.body.y + 70, 'bombFire'); bombsFire = bombFire.getFirstExists(true); if(bombsFire){ game.physics.enable(bombsFire, Phaser.Physics.ARCADE); bombsFire.body.gravity.y = gravitation; bombsFire.body.velocity.x =320; bombsFire.animations.add('bombFire'); bombsFire.animations.play('bombFire',20, true); // game.physics.arcade.collide(bombsFire, floors); } } } Also I tried forEach on update() and in function bombFires() and addChild to my hero. But nothing help. bombFire.forEach(function(){ game.physics.arcade.collide(bombFire, floors); console.log(game.physics.arcade.collide(bombsFire, floors)) }, this); Can anyone tell me what I do wrong? I`ve no ideas already :( Link to comment Share on other sites More sharing options...
Recommended Posts