InputHandler#enableSnap()

enableSnap(snapX, snapY, onDrag, onRelease, snapOffsetX, snapOffsetY)

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 Argument Default Description
snapX number

The width of the grid cell to snap to.

snapY number

The height of the grid cell to snap to.

onDrag boolean <optional>
true

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

onRelease boolean <optional>
false

If true the sprite will snap to the grid when released.

snapOffsetX number <optional>
0

Used to offset the top-left starting point of the snap grid.

snapOffsetY number <optional>
0

Used to offset the top-left starting point of the snap grid.

Source code: input/InputHandler.js (Line 1614)
doc_phaser
2017-02-14 10:53:21
Comments
Leave a Comment

Please login to continue.