Jump to content

Arcade overlap / collision bug


blackgames
 Share

Recommended Posts

Hi,

 

I have a problem with collision.

 

I have a sprite:

zombie = game.add.sprite(100, 100, 'zom');var x = 10;var y = 500zombie.reset(x, y);

and a group:

pigs = game.add.group();pigs.createMultiple(19, 'pig');var x_fix = 10; var y_fix = 495;
 
with the same position (debuginformation):
post-7633-0-83379100-1395601667.png
 
but the code in update function not worked:
game.physics.arcade.overlap(zombie, this.pigs, this.dead, null, this);
 
but the sprites are overlaped:
post-7633-0-40756000-1395601667.png
 
I use phaser 2.0.1 and I also try 2.0.0
 
I tried to enable physics, add a bigger bounding box, too use two sprites and not an group. Nothing worked for me
 
Please help - I going crazy!  :(
Link to comment
Share on other sites

collision bug? this work for me...

game.physics.startSystem(Phaser.Physics.ARCADE);

this.player = game.add.sprite(x,y,"nameImage")

game.physics.arcade.enable(this.player);

this.object = game.add.group();

this.object.createMultiple(5,"nameImage");

game.physics.arcade.enable(this.object,true);

//new object

function new (){

var any = this.object.getFirstExists(false)

if(any){

//some

any.x

any.y

any.reset()

}

}

//UPDATE

game.physics.arcade.overlap(this.player,this.object,this.callback,null,this);

callback(a,B){

//some b.kill(), b.y+=100...etc

}

Link to comment
Share on other sites

I would try this against the 2.0.1 build files that I literally uploaded a few minutes ago (remember it's still in dev, so subject to change as much as is needed before release - however overlapping is working fine now and several test cases were made for it)

Link to comment
Share on other sites

Thanks everybody,

 

this works fine for me:

--> Update to the new Version 2.0.1

game.physics.startSystem(Phaser.Physics.ARCADE);game.physics.arcade.enable(this.zombie);game.physics.arcade.enable(this.pigs);
 
But the next Problem shows:
If I make a tween off the sprites like this...
var x_fix = 20;var y_fix = 20;var x_tween = 10;var y_tween = 10;pig.reset(x_tween, y_tween);                    game.add.tween(pig).to( {x: x_fix, y: y_fix, alpha: 1}, 500, Phaser.Easing.Linear.None).start();
 
...the sprites are fly over the whole screen and never stops....
 
still missing another parameter? I tried immoveable, gravity, allowGravity... 
 
Please help again. I firmly hang
Link to comment
Share on other sites

You don't need to use physics at all if all you're doing is checking for an overlap. Especially if you want to use lots of tweens and the like.

 

Here I've put together 2 examples for you:

 

http://examples.phaser.io/_site/view_full.html?d=sprites&f=overlap+without+physics.js&t=overlap%20without%20physics

 

and

 

http://examples.phaser.io/_site/view_full.html?d=sprites&f=overlap+tween+without+physics.js&t=overlap%20tween%20without%20physics

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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