Skip to content

Phaser.Math.Wrap inconsitent behaviour #6479

@EmilSV

Description

@EmilSV

Version

  • Phaser Version: 3.60

Description

After the 3.60 wrap change to have check that made sure if it was in the range it return the same result.

    if (value >= min && value <= max)
    {
        //  Skip modulo if already in range
        return value;
    }

But if that will lead to inconsistent behavior if the value is out of range for example
wrap(4,0,4) == 4
wrap(8,0,4) == 0
But is should be the same because 8 is double of 4.

Before 3.60 the check was not there and wrap was consistent.

Example Test Code

console.log(Phaser.Math.Wrap(4,0,4)); // 4
console.log(Phaser.Math.Wrap(8,0,4)); // 0
console.log(Phaser.Math.Wrap(8,0,4) === Phaser.Math.Wrap(4,0,4)); //false

Additional Information

I don't know if this it intended behavior or a bug, if it is bug the i gladly make a pull request with the required changes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions