Jump to content

body.immovable=true and game.physics.arcade.overlap not working...


universaljs
 Share

Recommended Posts

Hi,

if in "create" function is kladka.body.immovable = true; then in "update" function this not working:

    game.physics.arcade.overlap(kladki, player, function(){
        console.log("x");
    },null, this);

Is it possible to do that work?

more code:

[...]

function create(){
	kladki = game.add.group();
	kladki.enableBody = true;
	var kladka = kladki.create(4*tileSize, 45*tileSize, 'kladka');
	game.physics.enable(kladka, Phaser.Physics.ARCADE);
	kladka.body.collideWorldBounds = true;
	kladka.body.allowGravity = false;
	
	kladka.body.immovable = true;
}

function update() {
	game.physics.arcade.collide(kladki, player);
	game.physics.arcade.collide(kladki, layer);


	// if in create functions is kladka.body.immovable = true; this not working:
	game.physics.arcade.overlap(kladki, player, function(){
		console.log("x");
	},null, this);
}

[...]

 

Link to comment
Share on other sites

Ok, thx! but when strapped version 2.4.7 - still dos't detect a collision (physically collision works but I need callback function at the time of the collision)...

When there are 2 objects to the set collisions, then at the moment when one object is enabled gravitation (player.body.allowGravity = true;) and the other has disabled gravitation (kladka.body.allowGravity = false;) at a time when the player will jump on this object - a gravity player turns gravity on the object "Kladka" ... is it possible to block it?

I tried the following: kladka.body.immovable = true; - but then there is a problem, which I described earlier ... I need detect a collision there (I need a callback function) ... like this:

		game.physics.arcade.overlap(kladki, player, function(){
			// callback
		},null, this);

Do you have any idea?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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