Archer3CL Posted July 19, 2014 Share Posted July 19, 2014 Hi!This time I'm trying to make 2 sprites (enemies vs bullets) collide (group vs sprite). I can detect and execute my function when the objects collide but when they do... the 'enemy' sprite pull back a little and I dont want this.What I want is that when the bullet collide with de enemy, the bullet disappear and the enemy keep moving forward. I'm using Arcade Physics and this is the code. Updatefunction update() { game.physics.arcade.collide(enemies, bullet, destroy, null, this);}Destroyfunction destroy(bullet, enemy) { var result = checkIfWeak(enemy, bullet); switch (result) { case 0: enemy.destroy(); bullet.destroy(); break; case 1: bullet.destroy(); break; }}Enemy and Bullet physic properties//Enemygame.physics.arcade.enable(enemy);enemy.body.acceleration.y += 25;//Bulletgame.physics.arcade.enable(bullet);bullet.body.acceleration.y -= 50;And my next question is: Does Phaser have an option to keep my game running even after the user is no longer on the window / tab / browser? Thanks for the help Link to comment Share on other sites More sharing options...
lewster32 Posted July 19, 2014 Share Posted July 19, 2014 Instead of using collide, use overlap - this just detects when they touch, whereas collide applies some separation logic to make it look like they've hit each other.function update() { game.physics.arcade.overlap(enemies, bullet, destroy, null, this);}Does Phaser have an option to keep my game running even after the user is no longer on the window / tab / browser? Yes, in your preload or create function just add the following:game.stage.disableVisibilityChange = true; Archer3CL 1 Link to comment Share on other sites More sharing options...
Archer3CL Posted July 20, 2014 Author Share Posted July 20, 2014 Thanks for the help. lewster32 1 Link to comment Share on other sites More sharing options...
Recommended Posts