-
Notifications
You must be signed in to change notification settings - Fork 0
Input.Pointer.API
A class that eases the use of mouse and touch, by providing functions for checking the current state of both.
Constructor for the Pointer class
- Source:
-
<private> calculateRoomPosition(vector) → {Math.Vector}
-
Converts a coordinate which is relative to the main canvas to a position in the room (based on the room's cameras)
Name Type Description vector
Math.Vector A vector representing a position which is relative to the main canvas
- Source:
vector A vector representing the calculated position relative to the room
- Type
- Math.Vector
-
Checks the state of a pointer object
Name Type Description pointers
Object | Array.<Object> A pointer object or an array of pointer objects to check the state of
state
string A state to check for "pressed", "released" or "down"
- Source:
Whether or not the pointer or one of the pointers has the provided state
- Type
- boolean
-
Finds the first available spot in the Pointer.touches-array, used for registering the touches as numbers from 0-9. In Google Chrome, each touch's identifier can be used directly since the numbers - starting from 0 - are reused, when the a touch is released. In Safari however each touch has a unique id (a humongous number), and a function (this) is therefore needed for identifying the touches as the numbers 0-9, which can be used in the Pointer.touches-array.
- Source:
The first available spot in the Pointer.touches-array where a new touch can be registered. If no spot is available, false is returned
- Type
- number | boolean
-
Returns a string representing the button type.
Name Type Description button
number A pointer button constant representing the button
- Source:
A string representing the type of button ("mouse", "touch" or "any")
- Type
- string
-
isDown(button) → {Array.<Object>|boolean}
-
Checks if a mouse button or touch is currently down.
Name Type Description button
number A pointer constant representing the pointer to check
- Source:
Returns an array containing the pointers that are currently down, or false if no pointers are down
- Type
- Array.<Object> | boolean
-
isPressed(button) → {Array.<Object>|boolean}
-
Checks if a mouse button or touch has just been pressed (between the last and the current frame).
Name Type Description button
number A pointer constant representing the pointer to check
- Source:
Returns an array containing the pointers that have just been pressed, or false if no pressed pointers where detected
- Type
- Array.<Object> | boolean
-
isReleased(button) → {Array.<Object>|boolean}
-
Checks if a mouse button or touch just been released (between the last and the current frame).
Name Type Description button
number A pointer constant representing the pointer to check
- Source:
Returns an array containing the pointers that have just been released, or false if no released pointers where detected
- Type
- Array.<Object> | boolean
-
Checks if the mouse has been moved between the last and the current frame.
- Source:
True if the pointer has been moved, false if not
- Type
- boolean
-
Registers every onmousedown event to the Mouse object.
Name Type Description event
MouseEvent Event object passed by the onmousedown event
- Source:
-
Registers every onmousemove event to the Mouse object.
Name Type Description event
MouseEvent Event object passed by the onmousemove event
- Source:
-
Registers every onmouseup event to the Mouse object.
Name Type Description event
MouseEvent Event object passed by the onmouseup event
- Source:
-
Registers every ontouchend event to the Mouse object.
Name Type Description event
TouchEvent Event object passed by the ontouchend event
- Source:
-
Registers every ontouchmove event to the Mouse object.
Name Type Description event
TouchEvent Event object passed by the ontouchmove event
- Source:
-
Registers every ontouchstart event to the Mouse object.
Name Type Description event
TouchEvent Event object passed by the ontouchstart event
- Source:
-
Checks if the mouse pointer is outside the game arena.
- Source:
True if the pointer is outside, false if not
- Type
- boolean
-
Releases a button, and thereby prevents the button from being detected as "pressed" by the isPressed function. This function is very useful for preventing one button press from having multiple effects inside the game. For instance on buttons that are placed on top of each other.
Name Type Description button
number The button to release
- Source:
True if the button has now been released, false if the button was not already pressed
- Type
- boolean
-
Resets the mouse cursor, automatically called by the engine before each frame i executed, unless engine.resetCursorOnEachFrame is set to false
- Source:
-
Sets the mouse cursor for the arena. By default the mouse cursor will be reset on each frame (this can be changed with the "resetCursorOnEachFrame" engine option) Please be aware that not all images can be used as cursor. Not all sizes and formats are supported by all browsers.
Name Type Description A
string resource string, image path string or css cursor of the cursor
- Source:
-
shapeIsDown(button, shape, outside) → {Array.<Object>|boolean}
-
Checks if an area defined by a geometric shape, or its outside, is down (currently clicked by mouse or touch). The shape can be any geometric object that has a contains function (Rectangle, Polygon).
Name Type Description button
button A pointer constant representing the pointers to check
shape
Math.Rectangle | Math.Polygon | Math.Circle A geometric shape defining the area to check
outside
boolean [Whether or not to check the outside of the specified area]
- Source:
An array containing the pointers that are currently pressing the shape, or false if no pointers inside the shape were detected
- Type
- Array.<Object> | boolean
-
Checks if an area defined by a geometric shape, or its outside, is hovered by the mouse pointer. The shape can be any geometric object that has a contains function (Rectangle, Polygon).
Name Type Description shape
Math.Rectangle | Math.Polygon | Math.Circle A geometric shape defining the area to check
outside
boolean [Whether or not to check the outside of the specified area]
- Source:
True if the shape if hovered, false if not
- Type
- boolean
-
shapeIsPressed(button, shape, outside) → {Array.<Object>|boolean}
-
Checks if an area defined by a geometric shape, or its outside, has just been pressed (between the last and the current frame). The shape can be any geometric object that has a contains function (Rectangle, Polygon).
Name Type Description button
button A pointer constant representing the pointers to check
shape
Math.Rectangle | Math.Polygon | Math.Circle A geometric shape defining the area to check
outside
boolean [Whether or not to check the outside of the specified area]
- Source:
An array containing the pointers that have pressed the shape, or false if no presses inside the shape were detected
- Type
- Array.<Object> | boolean
-
shapeIsReleased(button, shape, outside) → {Array.<Object>|boolean}
-
Checks if an area defined by a geometric shape, or its outside, has just been released (between the last and the current frame). The shape can be any geometric object that has a contains function (Rectangle, Polygon).
Name Type Description button
button A pointer constant representing the pointers to check
shape
Math.Rectangle | Math.Polygon | Math.Circle A geometric shape defining the area to check
outside
boolean [Whether or not to check the outside of the specified area]
- Source:
An array containing the pointers that have released the shape, or false if no releases inside the shape were detected
- Type
- Array.<Object> | boolean
Generated with wicked.
- Engine.Camera
- Engine.CustomLoop
- Engine.Loader
- Engine.Room
- Engine
- Input.Keyboard
- Input.Pointer
- Math.Circle
- Math.Line
- Math.Polygon
- Math.Rectangle
- Math.Vector
- Sound.Effect
- Sound.Music
- View.Child
- View.Circle
- View.Collidable
- View.Container
- View.GameObject
- View.Line
- View.Polygon
- View.Rectangle
- View.Sprite
- View.TextBlock
- global