HTML and CSS Reference
In-Depth Information
game.stage.on('stagemousedown', function(e){
if (!isPlaying) { return; }
game.tickWhenDown = cjs.Ticker.getTicks();
game.stage.on('stagemouseup', function(e){
if (!isPlaying) { return; }
game.tickWhenUp = cjs.Ticker.getTicks();
ticksDiff = game.tickWhenUp - game.tickWhenDown;
game.physics.shootBall(e.stageX, e.stageY, ticksDiff);
setTimeout(game.spawnBall, 500);
9. Finally, we spawn another ball after the last ball is thrown:
game.spawnBall = function() {
After performing these steps, we should get the result as shown in the following screenshot.
We can click anywhere on the screen; once the mouse buton is released, the ball is thrown
towards the posiion of the cursor. When the angle and power is right, the ball is thrown into
the hoop.
Objective complete - mini debriefing
Thanks to the physics engine, we only have to deine the posiion of the objects, throwing
angle, and power to create the enire ball-throwing logic. The engine automaically calculates
the path of the throw and the bounce of the ball.
Search WWH ::

Custom Search