From 1310daa9af75411afe46f0a5b98612f89d5c259f Mon Sep 17 00:00:00 2001 From: Taylan Kasap Date: Sun, 7 Feb 2016 14:19:28 +0200 Subject: [PATCH] Added RandomDataGenerator.sign (returns -1 or +1) --- src/math/RandomDataGenerator.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/math/RandomDataGenerator.js b/src/math/RandomDataGenerator.js index 86de909e5..da1da286f 100644 --- a/src/math/RandomDataGenerator.js +++ b/src/math/RandomDataGenerator.js @@ -268,6 +268,18 @@ Phaser.RandomDataGenerator.prototype = { }, + /** + * Returns a sign to be used with multiplication operator. + * + * @method Phaser.RandomDataGenerator#sign + * @return {number} -1 or +1. + */ + sign: function () { + + return this.pick([-1, 1]); + + }, + /** * Returns a random member of `array`, favoring the earlier entries. *