Sunday, May 3, 2009

fan effect code done

i was thinking of making something with Fan
so i did 1 module as how can one make object to sustain in AIR. :)
well the concept behind this is just make one Base object and one target Object
then find this distance between them and applyforce in y direction

like this
var forcex=Math.round(body.GetPosition().x-wallB.GetPosition().x);
var forcey=Math.round(body.GetPosition().y-wallB.GetPosition().y);

if (Math.abs(forcex)>=1&&Math.abs(forcey)>=1) {
body.ApplyForce( new b2Vec2(10/forcex, 50/forcey), body.GetWorldCenter());

No comments: