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
isEmptyObjectobjObjectreturns TRUE if obj is empty, that is, has zero properties.
isNumericstringStringreturns TRUE if string is numeric (0-9).
getTypeparameterMixedreturns the parameter type. Possible values:

  • 'number'
  • 'boolean'
  • 'string'
  • 'function'
  • 'regexp'
  • 'array'
  • 'date'
  • 'error'
  • 'arguments'
getLengthparameterMixedreturns the length of parameter. Parameter can be an object, string, or array.
convertRgbToHexrgbNumberreturns the hex value of rgb.
convertHexToRgbhexStringreturns the rgb value of hex
convertRadToDegradNumberreturns the degree value of rad.
randomIntegerminNumberthe minimum range (inclusive) for random number to be returned.
maxNumberthe maximum range (inclusive) for random number to be returned.
searchObjectssearches the haystack of objects for properties that match the value. If found, returns the corresponding index in the haystack, otherwise, returns -1.
propertyStringthe property to search on.
valueStringthe value of the property to match.
haystackArraythe array of objects to search in.
searchObjectsAdvsearches 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.
needleObjectthe object to match property values to.
haystackArraythe array of objects to search in.
inArraysearches for a needle in a haystack. If found, returns TRUE, otherwise FALSE.
needleStringthe string to search in the haystack for.
haystackArraythe array to search the needle string in.
makeEvennumberNumberconverts 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.