November 2011
Intermediate to advanced
348 pages
7h 2m
English
In this recipe, we'll try out our Animation class by creating a simple linear motion animation by moving a box from the left of the canvas to the right of the canvas:

Follow these steps to move a box from one side of the canvas to the other:
Animation class:<head>
<script src="animation.js">
</script>Animation object and get the canvas context: <script>
window.onload = function(){
var anim = new Animation("myCanvas");
var canvas = anim.getCanvas();
var context = anim.getContext();box object that contains the box's position and size:var linearSpeed ...
Read now
Unlock full access