Copy link to clipboard
Copied
I used the code from here: https://createjs.com/tutorials/HitTest/
This is what I have in the Adobe Animate canvas project:
createjs.Ticker.on("tick", tick);
function tick(event) {
var p = exportRoot.globalToLocal(stage.mouseX, stage.mouseY);
exportRoot.Pinky.alpha = 0.2;
if (exportRoot.Pinky.hitTest(p.x, p.y)) { exportRoot.Pinky.alpha = 1; }
stage.update(event);
}
What's happening is that the hitTest is only true when hitting the top left corner of the canvas instead of when hitting the MovieClip from any angle.
This seems to work. I'll need to test it more. I'm not really sure why the hitTest is off by the target's x/y coordinates, though.
if (exportRoot.Pinky.hitTest((p.x-exportRoot.Pinky.x), (p.y-exportRoot.Pinky.y))) { exportRoot.Pinky.alpha = 1; }
Copy link to clipboard
Copied
This seems to work. I'll need to test it more. I'm not really sure why the hitTest is off by the target's x/y coordinates, though.
if (exportRoot.Pinky.hitTest((p.x-exportRoot.Pinky.x), (p.y-exportRoot.Pinky.y))) { exportRoot.Pinky.alpha = 1; }