Jump to content

p2.js strange behaviour


Recommended Posts


I'm having some odd behaviour.

I made simple particle emiter for blood. and it's working awesome...in top half part of the map..no idea why.

my code:

function bloodEmiter(px,py){  for(var x=0; x<100; x++){    var drop = game.add.sprite(px, py,'bloodTexture');    game.physics.p2.enable(drop);    drop.body.setCollisionGroup(bloodGroup);    drop.body.collides([tilesGroup, bloodGroup]);    drop.body.velocity.y = game.rnd.integerInRange(-100, -500);    //drop.body.velocity.x = game.rnd.integerInRange(-14, 14);    drop.lifetime=game.rnd.integerInRange(100, 300);    drop.update = function(){      this.lifetime--;      if(this.lifetime==30)        game.add.tween(this).to({alpha: 0},1000).start();      if(this.lifetime<0)        this.destroy(true);    }  }}

bloodTexture is just 1x1 red pixel...but to the point:


my map height = 900.


iff i use my blodEmiter on y < 640 it looks like this:



if I use my emiter on y>=640 this is the effect:




there are no other differences than y position..... so why?


Please help. 


Link to comment
Share on other sites

Only thing I can think of is maybe there is something else affecting your blood drops...

Aside from the dual if statements instead of else if, or an onComplete handler instead to deal with killing drops, the code looks fine to me...


Your not strangely twisting gravity or something above 640...?

Link to comment
Share on other sites

  Does the same thing if you turn off blood/tile collision?

- no, only when blood tiles collide with each other 

 What if you try spreading out the particles a bit when creating them?
 - same effect


If you change the collision shape of the blod particles? 

- emm.. how?

Link to comment
Share on other sites


  • Recently Browsing   0 members

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