Constructor
new Tickable()
- Description:
Create a new tickable object.
- Source:
Members
(static) LOG_ERRORS
- Description:
Debugging feature. Logs errors as they happen
- Source:
Debugging feature. Logs errors as they happen
(static) possibleScripts
- Description:
Returns a list of all possible events for this object.
- Source:
Returns a list of all possible events for this object.
hasContentfulScripts :boolean
- Description:
Checks if this object has a non-empty script.
- Source:
Checks if this object has a non-empty script.
Type:
- boolean
isScriptable :boolean
- Description:
Check if an object can have scripts attached to it. Helpful when iterating through a lot of different wick objects that may or may not be tickables. Always returns true.
- Source:
Check if an object can have scripts attached to it. Helpful when iterating through a lot of different wick objects that may or may not be tickables. Always returns true.
Type:
- boolean
onScreen :boolean
- Description:
Check if this object is currently visible in the project, based on its parent.
- Source:
Check if this object is currently visible in the project, based on its parent.
Type:
- boolean
scripts :Array.<object>
- Description:
The scripts on this object.
- Source:
The scripts on this object.
Type:
- Array.<object>
Methods
_runFunction(fn, name, parameters)
- Description:
_runFunction runs an event function while passing in necessary global and local parameters.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fn |
string | Function to run. |
name |
string | Name of the event function being run (i.e. keyDown) |
parameters |
Object | An object of key,value pairs to be passed as parameters to the function. |
addEventFn(name, fn)
- Description:
Attach a function to a given event.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the name of the event to attach a function to. |
fn |
function | the function to attach |
addScript(name, src)
- Description:
Add a new script to an object.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the event that will trigger the script. See Wick.Tickable.possibleScripts |
src |
string | The source code of the new script. |
getAvailableScripts() → {Array.<string>}
- Description:
Returns a list of script names which are not currently in use for this object.
- Source:
Returns:
Available script names.
- Type
- Array.<string>
getEventFns(name)
- Description:
Gets all functions attached to an event with a given name.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the event |
getScript(name) → {object}
- Description:
Get the script of this object that is triggered when the given event name happens.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the event. See Wick.Tickable.possibleScripts |
Returns:
the script with the given name. Can be null if the object doesn't have that script.
- Type
- object
hasScript(name) → {boolean}
- Description:
Check if the object has a script with the given event name.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the event. See Wick.Tickable.possibleScripts |
Returns:
True if the script with the given name exists
- Type
- boolean
onEvent(name, fn)
- Description:
Add a function to be called when an event happens.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the event to attach the function to. |
fn |
function | The function to call when the given event happens. |
removeScript(name)
- Description:
Remove the script that corresponds to a given event name.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the event. See Wick.Tickable.possibleScripts |
runScript(name, parameters) → {object}
- Description:
Run the script with the corresponding event name. Will not run the script if the object is marked as removed.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the event. See Wick.Tickable.possibleScripts |
parameters |
Object | An object containing key,value pairs of parameters to send to the script. |
Returns:
object containing error info if an error happened. Returns null if there was no error (script ran successfully)
- Type
- object
scheduleScript(name, parameters)
- Description:
Schedule a script to run at the end of the tick.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the script to run. See Tickable.possibleScripts |
parameters |
Object | An object consisting of key,value pairs which correspond to parameters to pass to the script. |
scriptIsContentful(name) → {boolean}
- Description:
Check if the object has a non-empty script with a given name.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the event. See Wick.Tickable.possibleScripts |
Returns:
True if the script with the given name has code
- Type
- boolean
tick() → {object}
- Description:
The tick routine to be called when the object ticks.
- Source:
Returns:
- An object with information about the result from ticking. Null if no errors occured, and the script ran successfully.
- Type
- object
updateScript(name, src)
- Description:
Changes the source of the script with the given event name.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the event that will trigger the script. See Wick.Tickable.possibleScripts |
src |
string | The source code of the script. |