Jump to content

Collision physics.collide .y++


rodrigezer
 Share

Recommended Posts

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

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

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...