traiq11alone Posted March 30, 2015 Share Posted March 30, 2015 Hi guys, somebody can please tell me how collide, push sprite go, tileSprite too. Read examples, find some solutions but i dont know whats wrong with my code: function preload(){ game.load.image('block1', 'block1.png'); game.load.image('block2', 'block2.png');}function create() { game.physics.startSystem(Phaser.Physics.ARCADE); game.stage.backgroundColor = '#ECF0DD'; block1 = game.add.sprite(500, 300, 'block1'); game.physics.arcade.enable(block1); block1.body.allowCollision = true; block2 = game.add.sprite(700, 300, 'block2'); game.physics.arcade.enable(block2); block2.body.allowCollision = true;}function update() { game.physics.arcade.collide(block1, block2); if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) { block1.body.x += 5; } else if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) { block1.body.x -= 5; } else if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) { block1.body.y -= 5; } else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) { block1.body.y += 5; }}var game = new Phaser.Game(900, 500, Phaser.CANVAS, 'game', {preload:preload, create:create,update:update}); Its just go through, dont collide at all. Can you please tell me how to collide left, right side too? Link to comment Share on other sites More sharing options...
traiq11alone Posted March 30, 2015 Author Share Posted March 30, 2015 Nevermind, I figure it out. Collide 2 body you need velocity Link to comment Share on other sites More sharing options...
Recommended Posts