1.1.0 • Published 7 years ago

kindred-component v1.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

kindred-component

npm.io npm.io npm.io

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.