Game Development Reference
In-Depth Information
sphereVector.push(sphere(170+i*150,410,40));
}
var force:b2Vec2=new b2Vec2(0,-15);
var forceByMass:b2Vec2=force.Copy();
forceByMass.Multiply(sphereVector[1].GetMass());
var forceByMassByTime:b2Vec2=forceByMass.Copy();
forceByMassByTime.Multiply(30);
var sphereCenter:b2Vec2=sphereVector[0].GetWorldCenter();
sphereVector[0].ApplyForce(forceByMassByTime,sphereCenter);
sphereCenter=sphereVector[1].GetWorldCenter();
sphereVector[1].ApplyImpulse(forceByMass,sphereCenter);
sphereVector[2].SetLinearVelocity(force);
addEventListener(Event.ENTER_FRAME,updateWorld);
}
The concept is the same we applied earlier wherein we create a new force and apply
it to the leftmost sphere. As said, I am multiplying the force used for the middle
sphere by 30 .
Test the movie and now all spheres will react in the same way:
 
Search WWH ::




Custom Search