rodrigezer Posted January 30, 2014 Share Posted January 30, 2014 Hello.i'm making a collision detec, i have it var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update:update }); var c1, c2 function preload() { game.load.image('caja', 'assets/objetos/caja.png'); } function create() { c1 = game.add.sprite(0,100, 'caja') c1.name = "c1" c1.body.immovable = true c2 = game.add.sprite(0,0, 'caja') c2.name = "c2" c2.body.velocity.y = 100; //when i use .velocity, the collision works } function update(){ // c2.y++ //BUT WHEN I WANT MOVE THE SPRITE THIS WAY, THE COLLISION DONT WORK. game.physics.collide(c1, c2, collisionHandler, null, this) } function collisionHandler(){ console.log("crash") }how can i do ? i need move the sprites around "x" and "y". Link to comment Share on other sites More sharing options...
XekeDeath Posted January 30, 2014 Share Posted January 30, 2014 Collisions currently require the colliding bodies to have a velocity that is not zero.sprite.body.velocity.y != 0; When 1.1.4 is finally released, you will be able to directly set the x/y values of the sprite body instead.You'll be pleased to know that in 1.1.4 you can set Sprite.body.x/y directly without having to use velocity and still get collision responses rodrigezer 1 Link to comment Share on other sites More sharing options...
rodrigezer Posted January 30, 2014 Author Share Posted January 30, 2014 oh...well then just wait for the new release. TY Link to comment Share on other sites More sharing options...
rich Posted January 31, 2014 Share Posted January 31, 2014 In the meantime you could use an overlap check (which doesn't care about velocity) and resolve it in your own callback. Link to comment Share on other sites More sharing options...
Recommended Posts