Jump to content

collide between objects dont work property?


jajaboto
 Share

Recommended Posts

Hello, i am creating very simple game. My current phase is to create some UI for mobs. Mobs should be blocked by some kind of wall, when he encounter a wall he is blocked for a few second but after a while wall is penetrated slowly by mob. Speed of penetrating encreasing with speed of moveing mobs.  Is that behavior is normal and i have to add some kind od extra logic in mobs UI to detect collision?? In my opinion that should be normal that objects is blocked by other if it find obstacle on the way? 

I past my code which is responsible for creating groups and move object.

Mob=function(x,y,game,group){   this.object=group.create(x,y,'mob1');   this.object.body.enableBody=true;   this.object.body.collideWorldBounds=true;   this.game=game;};Mob.prototype.update=function(){       this.object.x+=0.3*this.dirX;  //move object into left side    this.object.body.velocity.x = 0;    this.object.body.velocity.y = 0;}function create(){   (...)       wallsBlockGroup = game.add.group();    wallsBlockGroup.enableBody = true;    wallsBlockGroup.physicsBodyType = Phaser.Physics.ARCADE;    wallsBlockGroup.immovable=true;       // creating 2 blocks    var w = wallsBlockGroup.create(400, 50, 'wallBlock');    w.body.immovable = true;    w.body.enableBody=true;      var w = wallsBlockGroup.create(400, 90, 'wallBlock');    w.body.immovable = true;    w.body.enableBody=true;     // creating group for Mobs     mobsGroup=game.add.group();     mobsGroup.enableBody = true;     mobsGroup.collideWorldBounds=true;     game.physics.enable(mobsGroup, Phaser.Physics.ARCADE);      //creating       m=new Mob(550,70,game,mobsGroup);     mobsList.push(m);}

And how it look after a few seconds of blocked.o88ls1.jpg

Link to comment
Share on other sites

Thanks for sugestion  @JP91 , your advice resolve other problem: speed up with every move.

I resolve my problem by moving declaration of collisions betwen this two groups at the end of update function, after invoking of update mobs objects.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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