HTML and CSS Reference
In-Depth Information
Creating Boxes
Thereareafewchangesweneedtomakeforthisexamplefrom CH5EX23.html whenwecre-
ate the boxes. In the loop, we set the x position for the boxes to be right on top of each other,
instead of offset to the right. We no longer need the boxes to fall over on their own; the balls
we shoot at the boxes will do that for us!
the restitution to .1 so that they don't bounce around as much as they did in the last example:
var xpos = ( startX ) / scaleFactor ;
boxFixture . density = 20.0 ;
boxFixture . restitution = . 1 ;
Also, when we create the walls, we set the wall restitution to .5, which means objects will be
less apt to bounce around on top of them:
wallFixture . restitution = . 5 ;
Search WWH ::

Custom Search