diff --git a/README.md b/README.md index a1b93595..91ab51a7 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,7 @@ Updates: * Vastly improved visibility API support + pageshow/pagehide + focus/blur. Working across Chrome, IE, Firefox, iOS, Android (also fixes #161) * Pausing the game will now mute audio and resuming will un-mute, unless it was muted via the game (fixes #439) * ScaleManager has 2 new events: ScaleManager.enterFullScreen and ScaleManager.leaveFullScreen, so you can respond to fullscreen changes directly. +* RandomDataGenerator.integerInRange(min, max) now includes both `min` and `max` within its range (#501) Bug Fixes: diff --git a/examples/wip/rnd.js b/examples/wip/rnd.js new file mode 100644 index 00000000..9e9c0362 --- /dev/null +++ b/examples/wip/rnd.js @@ -0,0 +1,40 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + +} + +var sprite; + +function create() { + + for (var i = 0; i < 1000; i++) + { + var x = game.rnd.integerInRange(10, 20); + + if (x === 20) + { + console.log('>>>', x); + } + else if (x === 10) + { + console.log('---', x); + } + else + { + // console.log(x); + } + } + +} + +function update() { + + +} + +function render() { + +} diff --git a/src/math/RandomDataGenerator.js b/src/math/RandomDataGenerator.js index 6a7e95b6..c8f38db4 100644 --- a/src/math/RandomDataGenerator.js +++ b/src/math/RandomDataGenerator.js @@ -154,14 +154,15 @@ Phaser.RandomDataGenerator.prototype = { }, /** - * Returns a random integer between min and max. + * Returns a random integer between and including min and max. + * * @method Phaser.RandomDataGenerator#integerInRange * @param {number} min - The minimum value in the range. * @param {number} max - The maximum value in the range. * @return {number} A random number between min and max. */ integerInRange: function (min, max) { - return Math.floor(this.realInRange(min, max)); + return Math.round(this.realInRange(min, max)); }, /**