You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 14, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 14, 2023. It is now read-only.
It appears that an Actor is notified if a mouse event affects it by checking to see if the mouse event coordinates are contained within the bounding box of the Actor only.
I would like to see support for determining if you clicked on the actual pixels that the Actor paints on the canvas.
I am wondering how difficult it would be to implement this. I researched two approaches. First is using another canvas as a hit canvas described here: http://tschaub.net/blog/2011/03/31/canvas-hit-detection.html Not sure if that approach makes sense in CAAT's overall architecture. Second, is checking to see if a point is in the path of an Actor when it is drawn using isPointinPath described here: http://digitalarts.bgsu.edu/faculty/bonniem/Spring11/artc4330_1/notes/notes26.html If Actors are redrawn everytime the system checks to see if a mouse interaction occurred, I am thinking this might be doable.
Are you referring to actors that contain images, or to a general shape ?
The first thing, is definitely straighforward. Just extract the image's
alpha channel, and compare the alpha value at x,y coordinate values
supplied to every mouse/click functions.
The other one, is certainly trickier. CAAT has two different stages per
frame:
transformation and paint.
what you pretend is to know at input bubling time, whether the mouse is
inside what an actor painted. Definitely isPointInPath exists in the canvas
rendering context (ctx). But CAAT uses its own path implementation. If you
anyway use the ctx to draw your actor, you could definitely call
ctx.isPointInPath to know whether it lies inside/outside.
Activity
sntran commentedon May 16, 2013
I would second this. It may be easier with Box2D since you can loop through the fixture and check for mouse location is within any.
hyperandroid commentedon May 17, 2013
Are you referring to actors that contain images, or to a general shape ?
The first thing, is definitely straighforward. Just extract the image's
alpha channel, and compare the alpha value at x,y coordinate values
supplied to every mouse/click functions.
The other one, is certainly trickier. CAAT has two different stages per
frame:
transformation and paint.
what you pretend is to know at input bubling time, whether the mouse is
inside what an actor painted. Definitely isPointInPath exists in the canvas
rendering context (ctx). But CAAT uses its own path implementation. If you
anyway use the ctx to draw your actor, you could definitely call
ctx.isPointInPath to know whether it lies inside/outside.
What is your exact use case ?
2013/5/16 Son Tran-Nguyen notifications@github.com