pex-renderer
pex-renderer copied to clipboard
Add source to change events
Currently it's impossible to know who emitted the change in the callback
function onParamChange (name) {
console.log('param ${name} has changed')
}
// start listening
entity.transform.changed.add(onParamChange)
// done internaly by transform whenever position changes
entity.transform.dispatch('position')
// stop listening
entity.transform.changed.remove(onParamChange)
What about using the listenerContext param: add(listener, listenerContext, priority)
function onParamChange (name) {
console.log('param ${name} has changed')
console.log('From entity', this)
}
entity.transform.changed.add(onParamChange, entity)