mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Rectangle.randomX will return a random value located within the horizontal bounds of the Rectangle.
Rectangle.randomY will return a random value located within the vertical bounds of the Rectangle.
This commit is contained in:
parent
003403c832
commit
494c33a9f4
3 changed files with 36 additions and 0 deletions
|
@ -134,6 +134,8 @@ Version 2.0.6 - "Jornhill" - -in development-
|
|||
* Phaser.Utils.mixin will mix the source object into the destination object, returning the newly modified destination object.
|
||||
* You can now use `game.add.plugin` from the GameObjectFactory (thanks @alvinsight, #978)
|
||||
* Color.getWebRGB will now accept either an Object or numeric color value.
|
||||
* Rectangle.randomX will return a random value located within the horizontal bounds of the Rectangle.
|
||||
* Rectangle.randomY will return a random value located within the vertical bounds of the Rectangle.
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
|
2
build/phaser.d.ts
vendored
2
build/phaser.d.ts
vendored
|
@ -4104,6 +4104,8 @@ declare module Phaser {
|
|||
height: number;
|
||||
left: number;
|
||||
perimeter: number;
|
||||
randomX: number;
|
||||
randomY: number;
|
||||
right: number;
|
||||
top: number;
|
||||
topLeft: Phaser.Point;
|
||||
|
|
|
@ -463,6 +463,38 @@ Object.defineProperty(Phaser.Rectangle.prototype, "centerY", {
|
|||
|
||||
});
|
||||
|
||||
/**
|
||||
* A random value between the left and right values (inclusive) of the Rectangle.
|
||||
*
|
||||
* @name Phaser.Rectangle#randomX
|
||||
* @property {number} randomX - A random value between the left and right values (inclusive) of the Rectangle.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "randomX", {
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.x + (Math.random() * this.width);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* A random value between the top and bottom values (inclusive) of the Rectangle.
|
||||
*
|
||||
* @name Phaser.Rectangle#randomY
|
||||
* @property {number} randomY - A random value between the top and bottom values (inclusive) of the Rectangle.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "randomY", {
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.y + (Math.random() * this.height);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties.
|
||||
* However it does affect the height property, whereas changing the y value does not affect the height property.
|
||||
|
|
Loading…
Reference in a new issue