mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 06:30:38 +00:00
Math.between will return a value between the given min
and max
values.
This commit is contained in:
parent
ee6f277b31
commit
93b1f3eba1
3 changed files with 16 additions and 0 deletions
|
@ -345,6 +345,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
|
|||
* Game Objects including Sprite, Image, Particle, TilemapLayer, Text, BitmapText and TileSprite have a new property called `data`. This is an empty Object that Phaser will never touch internally, but your own code, or Phaser Plugins, can store Game Object specific data within it. This allows you to associate data with a Game Object without having to pollute or change its class shape.
|
||||
* TilemapLayers will now collide properly when they have a position that isn't set to 0x0. For example if you're stitching together several maps, one after the other, and manually adjust their `scrollX/Y` properties (thanks @Upperfoot #2522)
|
||||
* There are a bunch of new Phaser consts available to help with setting the angle of a Game Object. They are `Phaser.ANGLE_UP`, `ANGLE_DOWN`, `ANGLE_LEFT`, `ANGLE_RIGHT`, `ANGLE_NORTH_EAST`, `ANGLE_NORTH_WEST`, `ANGLE_SOUTH_EAST` and `ANGLE_SOUTH_WEST`.
|
||||
* Math.between will return a value between the given `min` and `max` values.
|
||||
|
||||
### Updates
|
||||
|
||||
|
|
|
@ -23,6 +23,20 @@ Phaser.Math = {
|
|||
*/
|
||||
PI2: Math.PI * 2,
|
||||
|
||||
/**
|
||||
* Returns a number between the `min` and `max` values.
|
||||
*
|
||||
* @method Phaser.Math#between
|
||||
* @param {number} min - The minimum value. Must be positive, and less than 'max'.
|
||||
* @param {number} max - The maximum value. Must be position, and greater than 'min'.
|
||||
* @return {number} A value between the range min to max.
|
||||
*/
|
||||
between: function (min, max) {
|
||||
|
||||
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Two number are fuzzyEqual if their difference is less than epsilon.
|
||||
*
|
||||
|
|
1
typescript/phaser.d.ts
vendored
1
typescript/phaser.d.ts
vendored
|
@ -2480,6 +2480,7 @@ declare module "phaser" {
|
|||
static angleBetweenPointsY(point1: Phaser.Point, point2: Phaser.Point): number;
|
||||
static average(...numbers: number[]): number;
|
||||
static bernstein(n: number, i: number): number;
|
||||
static between(min: number, max: number): number;
|
||||
static bezierInterpolation(v: number[], k: number): number;
|
||||
static catmullRom(p0: number, p1: number, p2: number, p3: number, t: number): number;
|
||||
static catmullRomInterpolation(v: number[], k: number): number;
|
||||
|
|
Loading…
Reference in a new issue