Skip to content

ExampleComponent

da772 edited this page Feb 27, 2020 · 2 revisions

Creating a Component

Components are used to add additional functionality to actors. Therefore, components need to be added onto an actor in order to function.

TestScene.java

@Override
public void OnBegin() {
   Actor myActor = new Actor("myActor"); // Creates new actor called my actor on this scene
   Component myComponent = new Component("myComponent") // Creates new component
   {
        @Override
        public void OnBegin() {
        // Called after owning actor's begin
        }
        @Override
        public void OnEnd() {
        // Called before owning actor's end
        }
    };
    myActor.AddComponent(myComponent); 

}

Destroying a Component

TestScene.java

@Override
public void OnBegin() {
   Actor myActor = new Actor("myActor"); // Creates new actor called my actor on this scene
   Component myComponent = new Component("myComponent");
   myActor.RemoveComponent("myComponent"); 
}

Previous | Next

Clone this wiki locally