kindred-component
v1.1.0
Published
Base class upon which to build Kindred components
Downloads
11
Readme
kindred-component
Base class upon which to build Kindred components. Most of the functionality for consuming these components can be found in kindred-node.
Usage
kindred-component
is designed to be used with ES6 classes. You may need to use a transpiler such as Babel to support older browsers.
const Component = require('kindred-component')
// Each component must have a unique string id, e.g. here it's "custom":
class CustomComponent extends Component('custom') {
init () {
// called when the component is first created
}
step () {
// called once per frame, intended for logic such
// as physics simulation and event handling
}
draw () {
// called once per frame, intended for anything
// related to rendering.
}
stop () {
// called when the component is no longer being used.
// use this to clean up after yourself.
}
}
module.exports = CustomComponent
License
MIT. See LICENSE.md for details.