kick.core.MouseInput Class
Provides an easy-to-use mouse input interface.
Example:
Constructor
kick.core.MouseInput
()
Example:
function SimpleMouseComponent(){
var mouseInput,
thisObj = this;
this.activated = function(){
mouseInput = kick.core.Engine.instance.mouseInput;
};
this.update = function(){
if (mouseInput.isButtonDown(0)){
var str = "Left mouse down at position "+mouseInput.mousePosition[0]+","+mouseInput.mousePosition[1];
console.log(str);
}
}
}
Item Index
Methods
Methods
frameUpdated
()
private
Resets the mouse position each frame (mouse buttons down and delta values)
isButton
-
mouseButton
Parameters:
-
mouseButton
Number
Returns:
true if mouseButton is down
isButtonDown
-
mouseButton
Parameters:
-
mouseButton
Number
Returns:
true if mouse button is pressed down in this frame
isButtonUp
-
mouseButton
Parameters:
-
mouseButton
Number
Returns:
true if mouseButton is released in this frame
updateCanvasElementPosition
()
Update the mouseInput with the relative position of the canvas element.
This method should be called whenever the canvas element is moved in the document.
This method is automatically on engine.canvasResized events.
updateCanvasElementPositionPrivate
()
private
Calculates an object with the x and y coordinates of the given object. Updates the objectPosition variable
Properties
mouseMovementEventsEnabled
Boolean
Default value is true
mousePosition
kick.math.Vec2
Returns the mouse position of the canvas element, where 0,0 is in the upper left corner.
mouseWheelPreventDefaultAction
Boolean
If set to true, the engine will prevent screen from scrolling when mouse wheel is used when mouse pointer
is over the canvas.
Default value is false
releaseMouseButtonOnMouseOut
Boolean
When true mouse buttons are auto released when mouse moves outside the canvas. If this is not true, then mouse up events may not be detected. This is important when listening for mouse drag events. Default true