HTML and CSS Reference
In-Depth Information
revoluteJointDef.bodyB = circle;
revoluteJointDef.collideConnected = false;
revoluteJointDef.maxMotorTorque = obstacle.maxTorque;
revoluteJointDef.motorSpeed = obstacle.motorSpeed;
revoluteJointDef.enableMotor = obstacle.enableMotor;
this.world.CreateJoint(revoluteJointDef);
};
2. Then, we update the level creaion code to take care of the new cross obstacle:
if (o.type === 'rect') {
// existing rect obstacle code goes here.
} else if (o.type === 'cross') {
this.createCross(o);
}
3. We define a new level with our new cross obstacle. Let's add the following level
deiniion into the levels array:
game.levels = [
{
hoopPosition: {x:50, y:160},
ballName: 'slow ball',
ballPosition: {x:350, y:250},
ballRandomRange: {x:80, y:80},
obstacles: [
{
type: 'cross',
graphicName: 'Cross',
position: {x: 165, y: 140},
length: 60,
width: 10,
enableMotor: true,
maxTorque: 25,
motorSpeed: 3.0
},
]
},
// existing levels definition goes here.
];
 
Search WWH ::




Custom Search