0.1.1 • Published 10 years ago
serpentity-contrib v0.1.1
Serpentity Shared Objects
Pre-made systems, nodes and components using serpentity to ease development with serpentity by providing commonly needed objects.
Usage
- Install with npm
npm install serpentity-contrib- Include in your project (assuming you're loading from the root, but this may vary in your project.)
<script src="/node_modules/serpentity-contrib/serpentity-contrib.js"></script>- Include specific objects as you require them.
<script src="/node_modules/serpentity-contrib/components/position.js"></script>What's Included?
Components
Components for Games
- Bounds: Provides
wandhto define an object that has bounds. - Collider: A simple box collider that has a
typeand a box, used to handle collider geometry independent from the other properties. - Motion: Provides properties for motion using acceleration and velocity.
- Polygons: An array of polygons that can be rendered for a simple polygon renderer.
- Position: Provides
xandyto define an object that has a position. - Weight: Provides
weightto define an object that has a weight.
Other Components
These components may be used for other types of demos.
- Analyser: intended to include an audio analyser.
- Configuration: a generic configuration holder.
Nodes
Note: If you need variations on these nodes, you can create a new one by extending an object with the node you want to target.
Nodes for Games
- Collider: Position + Motion + Collider
- Gravity: Position + Motion + Weight
- Movement: Bounds + Position + Motion
- PolygonRender: Position + Bounds + Polygons
Other Nodes
- Analyser: Analyser
- Configurable: Configuration
- ConfigurableAnalyser: Configuration + Analyser
Systems
Systems for Games
- Acceleration: changes velocity based on acceleration
- Gravity: changes
yacceleration if object has weight - Motion: Changes position based on velocity. Has very simple bounds
checking, and must be instantiated with a
boundsobject that has anxandyproperty.
Phaser Renderers
These renderers expect a game object, which is an instance of
Phaser.Game, and a resolution object which contains w and h
properties, in roder to properly render.
- PhaserColliderRenderer: renders colliders.
- PhaserPolygonRenderer: renders polygons, applying defaults where possible.
Other Systems
- FrequencyLogger: An example on how to use the analyser node to obtain data.
Factories
Helper factories to generate some prefab entities.
- AudioFactory: has a
createMicAnalysermethod that receives a serpentityengineand a callback that is called with the entity. This factory method initiates user media and creates an entity with an analyser node.