IgeClass

Method: addComponent

Creates a new instance of the component argument passing the options argument to the component as it is initialised. The new component instance is then added to "this" via a property name that is defined in the component class as "componentId".
addComponent (IgeClass component, Object options)
  • IgeClasscomponent The class definition of the component.
  • Objectoptions An options parameter to pass to the component on init.

Add the velocity component to an entity

var entity = new IgeEntity();
entity.addComponent(IgeVelocityComponent);

// Now that the component is added, we can access
// the component via it's namespace. Call the 
// "byAngleAndPower" method of the velocity component:
entity.velocity.byAngleAndPower(Math.radians(20), 0.1);
© Copyright 2013 Irrelon Software Limited. All Rights Reserved. UK Registered Company Number: 07522767
Isogenic (ī´sōjen´ik): Adj originating from a common source; possessing the same genetic composition.
Strange Things Happen at the One Two Point