Skip to content

Instantly share code, notes, and snippets.

@gamebuilderstudio
Last active December 15, 2015 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gamebuilderstudio/5240212 to your computer and use it in GitHub Desktop.
Save gamebuilderstudio/5240212 to your computer and use it in GitHub Desktop.
package com.gbs.plugins.components
{
import com.pblabs.engine.components.TickedComponent;
import com.pblabs.engine.entity.PropertyReference;
import flash.geom.Point;
public final class CustomGameEngineComponent extends TickedComponent
{
public var referencePositionOnSpatial : PropertyReference;
private var spatialPosition : Point;
public function CustomGameEngineComponent()
{
super();
}
override public function onTick(deltaTime:Number):void
{
super.onTick(deltaTime);
//Update the position Value on this component using the Spatial component's value
spatialPosition = owner.getProperty( referencePositionOnSpatial ) as Point;
}
//Called when this component is added to the parent entity
//Usually used for setup
override protected function onAdd():void
{
super.onAdd();
referencePositionOnSpatial = new PropertyReference("@Spatial.position");
}
//Called whenever this component is removed from the parent Entity
override protected function onRemove():void
{
super.onRemove();
}
//Called everytime the entity list on the parent Entity changes
override protected function onReset():void
{
super.onReset();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment