|
|
|
|
|
by _delirium
5777 days ago
|
|
> But does svg have javascript functions to make elements drawn interactive, like keyboard movements etc? (under the assumption that svg/canvas is one way. like only draw and not refer to the elements and edit props) Not sure about svg, but you're right that canvas doesn't support that sort of thing natively. It's one of the main things canvas-based game engines encapsulate, though. While the canvas loses all your higher-level object information once you write it (it's just a bunch of pixels), the engines keep track of object locations separately, and then map clicks on canvas (x,y) coordinates to the objects that were clicked on, which can then trigger a callback (sometimes with some additional features supported beyond the direct click-to-object mapping). |
|