topical media & game development
mobile-graphic-easel-tutorials-HitTest-hitTest.htm / htm
<!DOCTYPE html>
<html>
<head>
<title>EaselJS demo: hitTest</title>
<link href="../shared/demo.css" rel="stylesheet" type="text/css">
<script src="../../lib/easeljs-0.6.0.min.js"></script>
<script>
var stage, circle;
function init() {
stage = new createjs.Stage("demoCanvas");
circle = stage.addChild(new createjs.Shape());
circle.graphics.beginFill("red").drawCircle(50,50,50);
circle.x = 0;
circle.y = 0;
createjs.Ticker.addEventListener("tick", tick);
}
function tick(event) {
circle.alpha = 0.2;
if (circle.hitTest(stage.mouseX, stage.mouseY)) { circle.alpha = 1; }
stage.update(event);
}
</script>
</head>
<body onLoad="init();">
<canvas id="demoCanvas" width="300" height="100">
alternate content
</canvas>
</body>
</html>
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.