This is a slightly modified version of http://api.jquery.com/jQuery.extend/
Name | Type | Description |
---|---|---|
deep | boolean | Perform a deep copy? |
target | object | The target object to copy to. |
The extended object.
Gets an objects property by string.
Name | Type | Description |
---|---|---|
obj | object | The object to traverse. |
prop | string | The property whose value will be returned. |
the value of the property or null if property isn't found .
This is a slightly modified version of jQuery.isPlainObject.
A plain object is an object whose internal class property is [object Object].
Name | Type | Description |
---|---|---|
obj | object | The object to inspect. |
Mixes the source object into the destination object, returning the newly modified destination object.
Based on original code by @mudcube
Name | Type | Description |
---|---|---|
from | object | The object to copy (the source object). |
to | object | The object to copy to (the destination object). |
The modified destination object.
Mixes in an existing mixin object with the target.
Values in the mixin that have either get
or set
functions are created as properties via defineProperty
except if they also define a clone
method - if a clone method is defined that is called instead and
the result is assigned directly.
Name | Type | Argument | Default | Description |
---|---|---|---|---|
target | object | The target object to receive the new functions. | ||
mixin | object | The object to copy the functions from. | ||
replace | boolean | <optional> | false | If the target object already has a matching function should it be overwritten or not? |
Takes the given string and pads it out, to the length required, using the character
specified. For example if you need a string to be 6 characters long, you can call:
pad('bob', 6, '-', 2)
This would return: bob---
as it has padded it out to 6 characters, using the -
on the right.
You can also use it to pad numbers (they are always returned as strings):
pad(512, 6, '0', 1)
Would return: 000512
with the string padded to the left.
If you don't specify a direction it'll pad to both sides:
pad('c64', 7, '*')
Would return: **c64**
Name | Type | Argument | Default | Description |
---|---|---|---|---|
str | string | The target string. | ||
len | integer | <optional> | 0 | The number of characters to be added. |
pad | string | <optional> | " " | The string to pad it out with (defaults to a space). |
dir | integer | <optional> | 3 | The direction dir = 1 (left), 2 (right), 3 (both). |
The padded string.
Get a unit dimension from a string.
Name | Type | Description |
---|---|---|
size | string | number | The size to parse. |
dimension | number | The window dimension to check. |
The parsed dimension.
Takes the given string and reverses it, returning the reversed string.
For example if given the string Atari 520ST
it would return TS025 iratA
.
Name | Type | Description |
---|---|---|
string | string | The string to be reversed. |
The reversed string.
Sets an objects property by string.
Name | Type | Description |
---|---|---|
obj | object | The object to traverse |
prop | string | The property whose value will be changed |
The object on which the property was set.
Generate a random bool result based on the chance value.
Returns true or false based on the chance value (default 50%). For example if you wanted a player to have a 30% chance
of getting a bonus, call chanceRoll(30) - true means the chance passed, false means it failed.
Name | Type | Description |
---|---|---|
chance | number | The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%). |
True if the roll passed, or false otherwise.
Choose between one of two values randomly.
Name | Type | Description |
---|---|---|
choice1 | any | |
choice2 | any |
The randomly selected choice
© 2016 Richard Davey, Photon Storm Ltd.
Licensed under the MIT License.
http://phaser.io/docs/2.6.2/Phaser.Utils.html