Class: InputHandler

InputHandler

Description.

new InputHandler(game)

Constructor for Phaser InputHandler.

Parameters:
Name Type Description
game Phaser.Sprite

Description.

Source:

Members

allowHorizontalDrag

Properties:
Name Type Description
allowHorizontalDrag boolean

Description.

Default Value:
  • true
Source:

allowVerticalDrag

Properties:
Name Type Description
allowVerticalDrag boolean

Description.

Default Value:
  • true
Source:

boundsRect

Properties:
Name Type Description
boundsRect Description

A region of the game world within which the sprite is restricted during drag.

Default Value:
  • null
Source:

boundsSprite

Properties:
Name Type Description
boundsSprite Description

A Sprite the bounds of which this sprite is restricted during drag.

Default Value:
  • null
Source:

bringToTop

Properties:
Name Type Description
bringToTop boolean

Description.

Default Value:
  • false
Source:

consumePointerEvent

If this object is set to consume the pointer event then it will stop all propogation from this object on. For example if you had a stack of 6 sprites with the same priority IDs and one consumed the event, none of the others would receive it.

Properties:
Name Type Description
consumePointerEvent boolean
Default Value:
  • false
Source:

draggable

Properties:
Name Type Description
draggable boolean

Is this sprite allowed to be dragged by the mouse? true = yes, false = no

Default Value:
  • false
Source:

enabled

Properties:
Name Type Description
enabled boolean

Description.

Default Value:
  • false
Source:

first

Properties:
Name Type Description
first Description

Description.

Source:

game

Properties:
Name Type Description
game Phaser.Game

A reference to the currently running game.

Source:

isDragged

Properties:
Name Type Description
isDragged boolean

Description.

Default Value:
  • false
Source:

last

Properties:
Name Type Description
last Description

Description.

Source:

next

Properties:
Name Type Description
next Description

Description.

Default Value:
  • null
Source:

parent

Properties:
Name Type Description
parent Description

Description.

Default Value:
  • null
Source:

pixelPerfect

Properties:
Name Type Description
pixelPerfect number

Should we use pixel perfect hit detection? Warning: expensive. Only enable if you really need it!

Default Value:
  • false
Source:

pixelPerfectAlpha

Properties:
Name Type Description
pixelPerfectAlpha number

The alpha tolerance threshold. If the alpha value of the pixel matches or is above this value, it's considered a hit.

Default Value:
  • 255
Source:

prev

Properties:
Name Type Description
prev Description

Description.

Default Value:
  • null
Source:

priorityID

Properties:
Name Type Description
priorityID number

The PriorityID controls which Sprite receives an Input event first if they should overlap.

Default Value:
  • 0
Source:

snapOffset

Properties:
Name Type Description
snapOffset Description

Description.

Default Value:
  • null
Source:

snapOnDrag

Properties:
Name Type Description
snapOnDrag boolean

Description.

Default Value:
  • false
Source:

snapOnRelease

Properties:
Name Type Description
snapOnRelease boolean

Description.

Default Value:
  • false
Source:

snapX

Properties:
Name Type Description
snapX number

Description.

Default Value:
  • 0
Source:

snapY

Properties:
Name Type Description
snapY number

Description.

Default Value:
  • 0
Source:

sprite

Properties:
Name Type Description
sprite Phaser.Sprite

Description.

Source:

useHandCursor

Properties:
Name Type Description
useHandCursor boolean

Description.

Default Value:
  • false
Source:

Methods

checkBoundsRect()

Bounds Rect check for the sprite drag

Source:

checkBoundsSprite()

Parent Sprite Bounds check for the sprite drag.

Source:

checkPixel(x, y) → {boolean}

Description.

Parameters:
Name Type Description
x Description

Description.

y Description

Description.

Source:
Returns:
Type
boolean

checkPointerOver(pointer) → {boolean}

Checks if the given pointer is over this Sprite.

Parameters:
Name Type Description
pointer Pointer
Source:
Returns:
Type
boolean

destroy()

Clean up memory.

Source:

disableDrag()

Stops this sprite from being able to be dragged. If it is currently the target of an active drag it will be stopped immediately. Also disables any set callbacks.

Source:

disableSnap()

Stops the sprite from snapping to a grid during drag or release.

Source:

downDuration(pointer) → {number}

If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds.

Parameters:
Name Type Description
pointer Pointer
Source:
Returns:

The number of milliseconds the pointer has been pressed down on the Sprite, or -1 if not over.

Type
number

enableDrag(lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite)

Make this Sprite draggable by the mouse. You can also optionally set mouseStartDragCallback and mouseStopDragCallback

Parameters:
Name Type Description
lockCenter

If false the Sprite will drag from where you click it minus the dragOffset. If true it will center itself to the tip of the mouse pointer.

bringToTop

If true the Sprite will be bought to the top of the rendering list in its current Group.

pixelPerfect

If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box.

alphaThreshold

If using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed (default 255)

boundsRect

If you want to restrict the drag of this sprite to a specific FlxRect, pass the FlxRect here, otherwise it's free to drag anywhere

boundsSprite

If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here

Source:

enableSnap(snapX, snapY, onDrag, onRelease)

Make this Sprite snap to the given grid either during drag or when it's released. For example 16x16 as the snapX and snapY would make the sprite snap to every 16 pixels.

Parameters:
Name Type Description
snapX

The width of the grid cell in pixels

snapY

The height of the grid cell in pixels

onDrag

If true the sprite will snap to the grid while being dragged

onRelease

If true the sprite will snap to the grid when released

Source:

justOut(pointer, delay) → {boolean}

Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second)

Parameters:
Name Type Description
pointer Pointer
delay number

The time below which the pointer is considered as just out.

Source:
Returns:
Type
boolean

justOver(pointer, delay) → {boolean}

Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second)

Parameters:
Name Type Description
pointer Pointer
delay number

The time below which the pointer is considered as just over.

Source:
Returns:
Type
boolean

justPressed(pointer, delay) → {boolean}

Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second)

Parameters:
Name Type Description
pointer Pointer
delay number

The time below which the pointer is considered as just over.

Source:
Returns:
Type
boolean

justReleased(pointer, delay) → {boolean}

Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second)

Parameters:
Name Type Description
pointer Pointer
delay number

The time below which the pointer is considered as just out.

Source:
Returns:
Type
boolean

overDuration(pointer) → {number}

If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds.

Parameters:
Name Type Description
pointer Pointer
Source:
Returns:

The number of milliseconds the pointer has been over the Sprite, or -1 if not over.

Type
number

pointerDown(pointer) → {boolean}

If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true.

Parameters:
Name Type Description
pointer Pointer
Source:
Returns:
Type
boolean

pointerOut(pointer) → {boolean}

Is the Pointer outside of this Sprite?

Parameters:
Name Type Description
pointer Pointer
Source:
Returns:
Type
boolean

pointerOver(pointer)

Is the Pointer over this Sprite?

Parameters:
Name Type Description
pointer Pointer
Source:
Returns:

{bool

pointerTimeDown(pointer) → {number}

A timestamp representing when the Pointer first touched the touchscreen.

Parameters:
Name Type Description
pointer Pointer
Source:
Returns:
Type
number

pointerTimeOut(pointer) → {number}

A timestamp representing when the Pointer left the touchscreen.

Parameters:
Name Type Description
pointer Pointer
Source:
Returns:
Type
number

pointerTimeOut(pointer) → {number}

Is this sprite being dragged by the mouse or not?

Parameters:
Name Type Description
pointer Pointer
Source:
Returns:
Type
number

pointerTimeOver(pointer) → {number}

A timestamp representing when the Pointer first touched the touchscreen.

Parameters:
Name Type Description
pointer Pointer
Source:
Returns:
Type
number

pointerTimeUp(pointer) → {number}

A timestamp representing when the Pointer left the touchscreen.

Parameters:
Name Type Description
pointer Pointer
Source:
Returns:
Type
number

pointerUp(pointer) → {boolean}

If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true

Parameters:
Name Type Description
pointer Pointer
Source:
Returns:
Type
boolean

pointerX(pointer) → {number}

The x coordinate of the Input pointer, relative to the top-left of the parent Sprite. This value is only set when the pointer is over this Sprite.

Parameters:
Name Type Description
pointer Pointer
Source:
Returns:

The x coordinate of the Input pointer.

Type
number

pointerY(pointer) → {number}

The y coordinate of the Input pointer, relative to the top-left of the parent Sprite This value is only set when the pointer is over this Sprite.

Parameters:
Name Type Description
pointer Pointer
Source:
Returns:

The y coordinate of the Input pointer.

Type
number

reset()

Description.

Source:

setDragLock(allowHorizontal, allowVertical)

Restricts this sprite to drag movement only on the given axis. Note: If both are set to false the sprite will never move!

Parameters:
Name Type Description
allowHorizontal

To enable the sprite to be dragged horizontally set to true, otherwise false

allowVertical

To enable the sprite to be dragged vertically set to true, otherwise false

Source:

start(priority, useHandCursor) → {Phaser.Sprite}

Description.

Parameters:
Name Type Description
priority number

Description.

useHandCursor boolean

Description.

Source:
Returns:

Description.

Type
Phaser.Sprite

startDrag()

Called by Pointer when drag starts on this Sprite. Should not usually be called directly.

Source:

stop()

Description.

Source:

stopDrag()

Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly.

Source:

update(pointer)

Update.

Parameters:
Name Type Description
pointer Pointer
Source:

updateDrag(pointer) → {boolean}

Updates the Pointer drag on this Sprite.

Parameters:
Name Type Description
pointer Pointer
Source:
Returns:
Type
boolean
Phaser Copyright © 2012-2013 Photon Storm Ltd.
Documentation generated by JSDoc 3.2.0-dev on Wed Oct 02 2013 15:04:49 GMT+0100 (BST) using the DocStrap template.