Documentation
¶
Index ¶
- Constants
- type Cursor
- type Mouse
- type MouseComponent
- type MouseFace
- type MouseSystem
- func (m *MouseSystem) Add(basic *ecs.BasicEntity, mouse *MouseComponent, space *physics.SpaceComponent, ...)
- func (m *MouseSystem) AddByInterface(i ecs.Identifier)
- func (m *MouseSystem) New(w *ecs.World)
- func (m *MouseSystem) Priority() int
- func (m *MouseSystem) Remove(basic ecs.BasicEntity)
- func (m *MouseSystem) Update(dt float32)
- type Mouseable
- type NotMouseComponent
- type NotMouseable
Constants ¶
const ( //CursorNone is no visible cursor. CursorNone = iota //CursorArrow is an arrow cursor. CursorArrow //CursorCrosshair is a crosshair cursor. CursorCrosshair //CursorHand is a hand cursor. CursorHand //CursorIBeam is a text-editor I cursor. CursorIBeam //CursorHResize is the horizontal resize window cursor. CursorHResize //CursorVResize is the vertical resize window cursor. CursorVResize )
const MouseSystemPriority = 100
MouseSystemPriority is the priority of the MouseSystem
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cursor ¶
type Cursor uint8
Cursor is a reference to a GLFW-cursor - to be used with the `SetCursor` method.
type Mouse ¶
type Mouse struct {
// X is the current x position of the mouse in the game
X float32
// Y is the current y position of the mouse in the game
Y float32
// ScrollX is the current scrolled position on the x component
ScrollX float32
// ScrollY is the current scrolled position on the y component
ScrollY float32
// Action is the currently active Action
Action engo.Action
// Button is which button is being pressed on the mouse
Button engo.MouseButton
// Modifier is whether any modifier mouse buttons are being pressed
Modifer engo.Modifier
}
Mouse is the representation of the physical mouse
type MouseComponent ¶
type MouseComponent struct {
// Clicked is true whenever the Mouse was clicked over
// the entity space in this frame
Clicked bool
// Released is true whenever the left mouse button is released over the
// entity space in this frame
Released bool
// Hovered is true whenever the Mouse is hovering
// the entity space in this frame. This does not necessarily imply that
// the mouse button was pressed down in your entity space.
Hovered bool
// Dragged is true whenever the entity space was left-clicked,
// and then the mouse started moving (while holding)
Dragged bool
// RightClicked is true whenever the entity space was right-clicked
// in this frame
RightClicked bool
// RightDragged is true whenever the entity space was right-clicked,
// and then the mouse started moving (while holding)
RightDragged bool
// RightReleased is true whenever the right mouse button is released over
// the entity space in this frame. This does not necessarily imply that
// the mouse button was pressed down in your entity space.
RightReleased bool
// Enter is true whenever the Mouse entered the entity space in that frame,
// but wasn't in that space during the previous frame
Enter bool
// Leave is true whenever the Mouse was in the space on the previous frame,
// but now isn't
Leave bool
// Position of the mouse at any moment this is generally used
// in conjunction with Track = true
MouseX float32
MouseY float32
// Set manually this to true and your mouse component will track the mouse
// and your entity will always be able to receive an updated mouse
// component even if its space is not under the mouse cursor
// WARNING: you MUST know why you want to use this because it will
// have serious performance impacts if you have many entities with
// a MouseComponent in tracking mode.
// This is ideally used for a really small number of entities
// that must really be aware of the mouse details event when the
// mouse is not hovering them
Track bool
// Modifier is used to store the eventual modifiers that were pressed during
// the same time the different click events occurred
Modifier engo.Modifier
// contains filtered or unexported fields
}
MouseComponent is the location for the MouseSystem to store its results; to be used / viewed by other Systems
func (*MouseComponent) GetMouseComponent ¶
func (c *MouseComponent) GetMouseComponent() *MouseComponent
GetMouseComponent Provides container classes ability to fulfil the interface and be accessed more simply by systems, eg in AddByInterface Methods
type MouseFace ¶
type MouseFace interface {
GetMouseComponent() *MouseComponent
}
MouseFace allows typesafe access to an anonymouse child MouseComponent
type MouseSystem ¶
type MouseSystem struct {
// contains filtered or unexported fields
}
MouseSystem listens for mouse events, and changes value for MouseComponent accordingly
func (*MouseSystem) Add ¶
func (m *MouseSystem) Add(basic *ecs.BasicEntity, mouse *MouseComponent, space *physics.SpaceComponent, render *render.RenderComponent)
Add adds a new entity to the MouseSystem.
- RenderComponent is only required if you're using the HUDShader on this Entity.
- SpaceComponent is required whenever you want to know specific mouse-events on this Entity (like hover, click, etc.). If you don't need those, then you can omit the SpaceComponent.
- MouseComponent is always required.
- BasicEntity is always required.
func (*MouseSystem) AddByInterface ¶
func (m *MouseSystem) AddByInterface(i ecs.Identifier)
AddByInterface adds the Entity to the system as long as it satisfies, Mouseable. Any Entity containing a BasicEntity,MouseComponent, and RenderComponent, automatically does this.
func (*MouseSystem) New ¶
func (m *MouseSystem) New(w *ecs.World)
New initializes the MouseSystem. It is run before any updates.
func (*MouseSystem) Priority ¶
func (m *MouseSystem) Priority() int
Priority returns a priority higher than most, to ensure that this System runs before all others
func (*MouseSystem) Remove ¶
func (m *MouseSystem) Remove(basic ecs.BasicEntity)
Remove removes an entity from the MouseSystem.
func (*MouseSystem) Update ¶
func (m *MouseSystem) Update(dt float32)
Update updates all the entities in the MouseSystem.
type NotMouseComponent ¶
type NotMouseComponent struct{}
NotMouseComponent is used to flag an entity as not in the AudioSystem even if it has the proper components
func (*NotMouseComponent) GetNotMouseComponent ¶
func (n *NotMouseComponent) GetNotMouseComponent() *NotMouseComponent
GetNotMouseComponent implements the NotMousable interface
type NotMouseable ¶
type NotMouseable interface {
GetNotMouseComponent() *NotMouseComponent
}
NotMouseable is an interface used to flag an entity as not in the MouseSystem even if it has the proper components