Snap
Introduction¶
Snap a value to nearest grid slice, built-in methods of phaser.
- Author: Richard Davey
Usage¶
Round¶
var out = Phaser.Math.Snap.To(value, gap);
// var out = Phaser.Math.Snap.To(value, gap, start);
Example: set gap
to 5
- Set
value
to12
, return10
- Set
value
to14
, return15
Ceil¶
var out = Phaser.Math.Snap.Ceil(value, gap);
// var out = Phaser.Math.Snap.Ceil(value, gap, start);
Example: set gap
to 5
- Set
value
to12
, return15
- Set
value
to14
, return15
Floor¶
var out = Phaser.Math.Snap.Floor(value, gap);
// var out = Phaser.Math.Snap.Floor(value, gap, start);
Example: set gap
to 5
- Set
value
to12
, return10
- Set
value
to14
, return10