CanvasScript3
>
Tests
> DisplayObject - HitTestObject
Code
var stage = new Stage("canvas", 420, 500, 30); var circle1 = new Shape(); circle1.graphics.beginFill(0x0000FF); circle1.graphics.drawCircle(40, 40, 40); stage.addChild(circle1); var circle2 = new Shape(); circle2.graphics.beginFill(0x00FF00); circle2.graphics.drawCircle(40, 40, 40); circle2.x = 50; stage.addChild(circle2); var circle3 = new Shape(); circle3.graphics.beginFill(0xFF0000); circle3.graphics.drawCircle(40, 40, 40); circle3.x = 100; circle3.y = 67; stage.addChild(circle3); trace("result"); trace("answer"); trace("---------------------"); trace(circle1.hitTestObject(circle2)); // true trace("true"); trace("---------------------"); trace(circle1.hitTestObject(circle3)); // false trace("false"); trace("---------------------"); trace(circle2.hitTestObject(circle3)); // true trace("true"); trace("---------------------");
Canvas
Output