V
V
vasIvas2015-09-23 23:20:23
JavaScript
vasIvas, 2015-09-23 23:20:23

How to get currentTarget?

For me, this is not only a request for help, but also a litmus test. A litmus of real trollism.
Many times I heard about unflattering words about flash and about his murder. I heard a lot of reviews about pix, js,
phaser.js that they are just wonderful. I saw quite a few answers where users, whom I consider
experienced programmers, advised this or that framework.
And now, the moment of revelation .. There is a container in which figures of complex shape are added. What needs to be done to sign the container and when clicking only on the visible part of the figure, and not on its frame , get this very figure?
and some offtopic.
If you do not know the answer to such a simple question, how can you advise him?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Kitmanov, 2015-09-23
@k12th

I do not want to answer the question in such a tone, but nevertheless. If a complex figure is described in the form of vertex coordinates, then we google the algorithm for determining whether a point belongs to a polygon. If this is a sprite, then we copy it to an invisible canvas and use getImageData to check whether we hit a transparent point or not. In some frameworks, this is all probably already implemented, whether it is in pixi / phaser / another Framework - see the docs.
Yes, canvas api is very low level, it's not classified information.

N
Nazar Mokrinsky, 2015-09-24
@nazarpc

I used fabric.js to render custom interactive charts , there are click events on an arbitrary form element on the canvas as well. It is done very simply and conveniently , I don’t know about the mentioned tools, I didn’t advise)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question