zerk Class
The Zerk main object and namespace
Item Index
Methods
Properties
Methods
_classLoaded
-
className
Checks if a class is loaded and defined already
Parameters:
-
className
StringThe name of the class
Returns:
_classLoading
-
className
Checks if a class is loading already
Parameters:
-
className
StringThe name of the class
Returns:
_createObject
-
parent
Creates an object from parent object definition
This is an implementation of Douglas Crockfords prototypal inheritance in JavaScript.
Parameters:
-
parent
Object
Returns:
_defineClass
-
meta
-
body
-
callback
Defines a class
Parameters:
-
meta
ObjectClass meta object
-
body
ObjectClass body
-
callback
FunctionCallback function that fires after the class was defined
Returns:
_delayDefine
-
meta
-
body
-
callback
-
waitFor
Creates a delayed define entry and returns its handle
Parameters:
-
meta
ObjectClass meta object
-
body
ObjectClass body
-
callback
FunctionCallback function
-
waitFor
Array
Returns:
_getClassURL
-
className
Returns the url for given class name
Parameters:
-
className
StringThe name of the class
Returns:
_loadScript
-
url
Loads a JavaScript file
Parameters:
-
url
StringThe target url of the script to be loaded
_onLoad
()
private
Fires when all classes ever required are loaded and defined
_parseClassName
-
className
Parses given class name and returns detailed information
Parameters:
-
className
StringThe name of the class
Returns:
_parseMeta
-
meta
Normalize meta data
Parameters:
-
meta
String | ObjectA class meta data object or name
Returns:
_processLoadedClass
-
className
Process delayed defines after dependencies are resolved
Parameters:
-
className
StringThe name of the class
_ready
()
private
Fires when all classes ever required are loaded and defined and the document is ready
_requireClass
-
className
Loads the related script file of the given class name
Parameters:
-
className
String
apply
-
obj
-
props
Apply properties to an object/class
Parameters:
-
obj
ObjectThe object witch the properties should be applied to
-
props
ObjectA JSON property structure
create
-
name
Creates a class instance
All arguments after 'name' are passed to the init method of the class.
Parameters:
-
name
StringThe name of the class
Returns:
define
-
name
-
body
-
callback
Defines a new class
// Class definition without meta object
zerk.define('myNamespace.myClass',{
// ...
});
// Class definition with meta object
zerk.define({
name: 'myNamespace.myClass',
extend: 'myNamespace.myParentClass'
require: [
'myNamespace.myParentClass'
]
},{
// ...
});
Parameters:
-
name
String | ObjectThe name of the class or a meta object
-
body
ObjectThe body of the class
-
callback
FunctionCallback function that fires when the class definition is done
init
-
config
The main bootstrap method
Parameters:
-
config
ObjectConfiguration object
parent
-
name
Method for inheritance like parent class calls
Use this with the apply method to inject the local scope.
zerk.parent('myClass').myMethod.apply(
this,
arguments
);
Parameters:
-
name
StringThe name of the class
Returns:
Properties
_classMap
Object
private
Class name to instance map
_classState
Object
private
Load state of classes
_config
Object
private
The game engine configuration
_delayedDefine
Object
private
Defines that got delayed by requires