Last active
December 15, 2015 09:39
-
-
Save gamebuilderstudio/5240212 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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