Core. Utils

Utils Utility class.

Constructor

new Utils()

Member

(static) parseXMLFromString :function

Parse a string into a XML object.

Methods

bind(fun, scope) → {function}

Binds a function to an incoming function and returns a bound function.
Parameters:
Name Type Description
fun function Function object.
scope Object Function scope.
Returns:
Type:
function
Bound function.

fitDOMElementInArea(dom, coordinateSpace, x, y, width, height)

DOM elements are used within a region of the stage.
Parameters:
Name Type Description
dom Object DOM element reference
coordinateSpace Sprite Coordinate space cannot be a Stage reference
x Number Relative to the X coordinates of coordinateSpace
y Number Relative to the Y coordinates of coordinateSpace
width Number width
height Number height

getGID()

Gets a globally unique ID.

getGlobalPosAndScale(sprite) → {Rectangle}

Calculates incoming display objects Sprite Coordinates and scaling values of the global coordinate system are returned Rectangle The object stores the calculated coordinates, X values, Y values, ScaleX values, and ScaleY values.
Parameters:
Name Type Description
sprite Sprite Sprite Object.
Returns:
Type:
Rectangle
Rectangle object Rectangle

getTransformRelativeToWindow(coordinateSpace, x, y) → {Object}

Gets the transform in the specified area relative to the upper left corner of the window.
Parameters:
Name Type Description
coordinateSpace Sprite Coordinate space cannot be a Stage reference
x Number Relative to the X coordinates of coordinateSpace
y Number Relative to the Y coordinates of coordinateSpace
Returns:
Type:
Object

measureText(txt, font) → {Object}

Measures the width and height information of the text in the specified style.
Parameters:
Name Type Description
txt String Text content.
font String Text font style.
Returns:
Type:
Object
Text wide and high information objects. Such as: {width:xxx, height:xxx}

parseInt(str, radixopt) → {int}

Parse a string and return an integer. Unlike JS native parseInt: if STR is empty or non numeric, the native returns NaN, where 0 is returned.
Parameters:
Name Type Attributes Default Description
str String A string to be parsed.
radix int <optional>
0 radix The cardinality of the digits to be parsed. The default value is 0, indicating 10 hexadecimal, and the other values range from 2 to 36. If it starts with "0x" or "0X", it will be based on 16. If the parameter is not within the range above, this method returns 0.
Returns:
Type:
int
Returns the parsed number.

toAngle(radian) → {Number}

Radian is converted to angle.
Parameters:
Name Type Description
radian Number Radian value.
Returns:
Type:
Number
Return angle value.

toHexColor(color) → {String}

Converts an incoming uint type color value to a string type color value.
Parameters:
Name Type Description
color Number Color value.
Returns:
Type:
String
String color values.

toRadian()