HTML and CSS Reference
In-Depth Information
graphic.lineTo(0,0,0,25);
ball = new Shape(graphic);
ball.x = 50;
ball.y = 50;
ball.vx = 100;
ball.vy = 1000;
ball.pulse = 0;
ball.onPress = function() {
var direction = Math.random()*Math.PI*2;
ball.vx = Math.cos(direction) * 200;
ball.vy = Math.sin(direction) * 200;
}
stage.addChild(ball);
window.tick = function(dt) {
var seconds = dt / 1000;
ball.vy += 50 * seconds; // Add some gravity
ball.x += ball.vx * seconds;
ball.y += ball.vy * seconds;
ball.pulse += seconds;
ball.scaleX = 1 + Math.sin(ball.pulse)/2;
ball.scaleY = 1 + Math.sin(ball.pulse)/2;
ball.rotation += ball.vx * seconds;
if(ball.x + 25 > canvas.width) {
ball.vx = -Math.abs(ball.vx);
} else if(ball.x - 25 < 0) {
ball.vx = Math.abs(ball.vx);
}
if(ball.y + 25 > canvas.height) {
ball.vy = -Math.abs(ball.vy);
} else if(ball.y - 25 < 0) {
ball.vy = Math.abs(ball.vy);
}
stage.update();
}
Ticker.setFPS(60)
Ticker.addListener(window);
</script>
</body>
</html>
Search WWH ::




Custom Search