topical media & game development
sample-collect-hush-js-waterfall-files-basicShapes.js / js
function b2CreateBall(world, x, y, r, fixed) {
if (typeof(fixed) == 'undefined') fixed = true;
var ballSd = new b2CircleDef();
if (!fixed) ballSd.density = 1;
ballSd.radius = r;
ballSd.restitution = ballBounce + (Math.random()*(ballBounceBias*10))/10;
ballSd.friction = 0;
var ballBd = new b2BodyDef();
ballBd.AddShape(ballSd);
ballBd.position.Set(x,y);
return world.CreateBody(ballBd);
}
function b2CreateBox(world, x, y, width, height, fixed, r) {
if (typeof(fixed) == 'undefined') fixed = true;
if (typeof(r) == 'undefined') r = 0;
var boxSd = new b2BoxDef();
if (!fixed) boxSd.density = 1.0;
boxSd.restitution = groundBounce;
boxSd.friction = 0;
boxSd.extents.Set(width, height);
var boxBd = new b2BodyDef();
boxBd.AddShape(boxSd);
boxBd.position.Set(x,y);
boxBd.rotation = r;
return world.CreateBody(boxBd)
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.