Classes
Util
This class is a mix of utility functions that help with miscellaneous tasks. If you want to add your own global functions, it is recommended to use the GAME.custom.funcs
object to prevent namespace or scoping issues. Simply assign your own functions like this:
GAME.initCustom(function(){
GAME.custom.funcs.myCustomFunction = function(param1, param2, ...){
// do something
};
});
Methods (static)
Name | Parameter | Type | Description |
---|---|---|---|
isEmptyObject | obj | Object | returns TRUE if obj is empty, that is, has zero properties. |
isNumeric | string | String | returns TRUE if string is numeric (0-9). |
getType | parameter | Mixed | returns the parameter type. Possible values:
|
getLength | parameter | Mixed | returns the length of parameter. Parameter can be an object, string, or array. |
convertRgbToHex | rgb | Number | returns the hex value of rgb. |
convertHexToRgb | hex | String | returns the rgb value of hex |
convertRadToDeg | rad | Number | returns the degree value of rad. |
randomInteger | min | Number | the minimum range (inclusive) for random number to be returned. |
max | Number | the maximum range (inclusive) for random number to be returned. | |
searchObjects | searches the haystack of objects for properties that match the value. If found, returns the corresponding index in the haystack, otherwise, returns -1. | ||
property | String | the property to search on. | |
value | String | the value of the property to match. | |
haystack | Array | the array of objects to search in. | |
searchObjectsAdv | searches the haystack of objects for property values that match property values in the needle object. If found, returns the corresponding index in the haystack, otherwise, returns -1. | ||
needle | Object | the object to match property values to. | |
haystack | Array | the array of objects to search in. | |
inArray | searches for a needle in a haystack. If found, returns TRUE, otherwise FALSE. | ||
needle | String | the string to search in the haystack for. | |
haystack | Array | the array to search the needle string in. | |
makeEven | number | Number | converts number to an even number, if odd. This is helpful when evenly divisible pixel counts are required; ie, when an image is rendering blurry because of odd floating point values. |