mirror of
https://github.com/photonstorm/phaser
synced 2024-11-29 08:01:04 +00:00
Wrap shouldn't adjust a value already in the range
This commit is contained in:
parent
50d0aeb391
commit
5d75d771f8
1 changed files with 6 additions and 0 deletions
|
@ -18,6 +18,12 @@
|
|||
*/
|
||||
var Wrap = function (value, min, max)
|
||||
{
|
||||
if (value >= min && value <= max)
|
||||
{
|
||||
// Skip modulo if already in range
|
||||
return value;
|
||||
}
|
||||
|
||||
var range = max - min;
|
||||
|
||||
return (min + ((((value - min) % range) + range) % range));
|
||||
|
|
Loading…
Reference in a new issue