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
To implement mouse input, we need a system for detecting and transmitting mouse events such as mouse position and clicks.
Mouse positioning
Generally, elements such as interface items (e.g. buttons) or game items within the world which may be clickable require mouse position input. A proposed approach is as follows: entities may hold a mouseover component which has as its data the bounds (either in terms of the window, or the game world) which the component wants to "watch". A system then iterates through all mouseover components and checks the mouse position in that tick. It calculates both the absolute position relative to the window and to the center of the world, by converting the position into world coordinates by taking the position of the viewport and adding the position of the mouse relative to the window (adjusting for scaling). The system accordingly invokes a callback if the mouse is inside relevant bounds.
Mouse clicks
Similarly to above, entities may register a mouseclick component to watch for clicks. When a click occurs, all clickable entities are looped over and a callback function is fired.
It is additionally important to consider the z-index of indices so that overlapping entities' actions are not both executed. We may be able to utilise the scene graph for this, or we may let the user develop their own system; for example by adding layers and checking which layers are visible.
The text was updated successfully, but these errors were encountered:
To implement mouse input, we need a system for detecting and transmitting mouse events such as mouse position and clicks.
Mouse positioning
Generally, elements such as interface items (e.g. buttons) or game items within the world which may be clickable require mouse position input. A proposed approach is as follows: entities may hold a mouseover component which has as its data the bounds (either in terms of the window, or the game world) which the component wants to "watch". A system then iterates through all mouseover components and checks the mouse position in that tick. It calculates both the absolute position relative to the window and to the center of the world, by converting the position into world coordinates by taking the position of the viewport and adding the position of the mouse relative to the window (adjusting for scaling). The system accordingly invokes a callback if the mouse is inside relevant bounds.
Mouse clicks
Similarly to above, entities may register a mouseclick component to watch for clicks. When a click occurs, all clickable entities are looped over and a callback function is fired.
It is additionally important to consider the z-index of indices so that overlapping entities' actions are not both executed. We may be able to utilise the scene graph for this, or we may let the user develop their own system; for example by adding layers and checking which layers are visible.
The text was updated successfully, but these errors were encountered: