Hi
I've tested a lot, read the manual and searched in the internet (inclusive this board).
I want to count the Numbers of Particles in a Body. My m2Body is a simple Cup (ignore keyword 'bottle') on a line. This works:
I also have a b2ParticleSystem which generates approximately 2000 particles in one group. The group is placed above my cup and falls in gravity driection. A part of the b2ParticleGroup falls in the cup and a part falls away. Everything works fine and with no errors in the console.
But now I need a method to count the amount of particles, which are in the cup. Do you know some solutions to this?
Thank you for a reply! (Sorry for the bad English)
Kind regards mmpbox
I've tested a lot, read the manual and searched in the internet (inclusive this board).
I want to count the Numbers of Particles in a Body. My m2Body is a simple Cup (ignore keyword 'bottle') on a line. This works:
Code: Select all
bd = new b2BodyDef;
bd.type = b2_dynamicBody;
bd.position.Set(0, 0);
var body = world.CreateBody(bd);
shape = new b2PolygonShape;
var bottle1_x = -3.5;
var bottle1_y = 5;
var bottle1_scale = 0.8;
shape.vertices.push(new b2Vec2(bottle1_x + 0 * bottle1_scale, bottle1_y + 0 * bottle1_scale));
shape.vertices.push(new b2Vec2(bottle1_x + 0.5 * bottle1_scale, bottle1_y + -4 * bottle1_scale));
shape.vertices.push(new b2Vec2(bottle1_x + 0.7 * bottle1_scale, bottle1_y + -4 * bottle1_scale));
body.CreateFixtureFromShape(shape, 0.0);
shape = new b2PolygonShape;
bottle1_x = -3.5;
bottle1_y = 5;
bottle1_scale = 0.8;
shape.vertices.push(new b2Vec2(bottle1_x + 0.5 * bottle1_scale, bottle1_y + -4 * bottle1_scale));
shape.vertices.push(new b2Vec2(bottle1_x + 3.5 * bottle1_scale, bottle1_y + -4 * bottle1_scale));
shape.vertices.push(new b2Vec2(bottle1_x + 3.5 * bottle1_scale, bottle1_y + -3.8 * bottle1_scale));
shape.vertices.push(new b2Vec2(bottle1_x + 0.5 * bottle1_scale, bottle1_y + -3.8 * bottle1_scale));
body.CreateFixtureFromShape(shape, 0.1);
shape = new b2PolygonShape;
bottle1_x = -3.5;
bottle1_y = 5;
bottle1_scale = 0.8;
shape.vertices.push(new b2Vec2(bottle1_x + 3.5 * bottle1_scale, bottle1_y + -4 * bottle1_scale));
shape.vertices.push(new b2Vec2(bottle1_x + 4 * bottle1_scale, bottle1_y + 0 * bottle1_scale));
shape.vertices.push(new b2Vec2(bottle1_x + 3.3 * bottle1_scale, bottle1_y + -4 * bottle1_scale));
body.CreateFixtureFromShape(shape, 0.2);
I also have a b2ParticleSystem which generates approximately 2000 particles in one group. The group is placed above my cup and falls in gravity driection. A part of the b2ParticleGroup falls in the cup and a part falls away. Everything works fine and with no errors in the console.
But now I need a method to count the amount of particles, which are in the cup. Do you know some solutions to this?
Thank you for a reply! (Sorry for the bad English)
Kind regards mmpbox