Class: Utils

Utils

A collection of useful generic functions.

Methods

(static) createId() → {String}

Returns:
Type
String

(static) getRandomFloat(min, max) → {float}

Get a random float number between a min (inclusive) and max (exclusive) value

Parameters:
Name Type Description
min number

minimum value

max number

maximum value

Returns:
Type
float

(static) getRandomInt(min, max) → {integer}

Get a random integer number between a min (inclusive) and max (exclusive) value

Parameters:
Name Type Description
min number

minimum value

max number

maximum value

Returns:
Type
integer

(static) getUniqueName(name, nameArrayopt) → {string}

Parameters:
Name Type Attributes Description
name string

String name to make unique.

nameArray Array.<string> <optional>

Array of string names to check agains.

Returns:
Type
string

(static) wait(secondsopt, optionsopt) → {Deferred}

Return a deferred promise that will wait a given number of seconds before
resolving. Pass delta time in milliseconds to the deferred promise's execute
method in an update loop to progress time.

Parameters:
Name Type Attributes Default Description
seconds number <optional>
0

Number of seconds to wait before resolving.

options Object <optional>

Optional options object

Properties
Name Type Attributes Description
onFinish function <optional>

Callback to execute once the wait time
is met.

onProgress function <optional>

Callback to execute each time the wait
time progresses towards the target number of seconds. The amount of progress
as a 0-1 percentage is passed as an argument.

onCancel function <optional>

Callback to execute if the user cancels
the wait before completion.

onError function <optional>

Callback to execute if the wait stops
because an error is encountered. The error message is passed as a parameter.

Returns:
Type
Deferred