-
-
Notifications
You must be signed in to change notification settings - Fork 4
Actor
Brandon Dyer edited this page Dec 22, 2018
·
1 revision
class MyActor : public Kepler::Actor {
// Construct and give our Actor a name
MyActor(): Actor("MyActor") {}
// Create a new Entity to our Actor's spec
virtual void Create(Entity &entity) {
entity.AddComponent(new SomeComponent(x));
}
// Tick an Entity
virtual void Tick(Entity &entity, float delta) {
SomeComponent *component = entity.GetComponent<SomeComponent>();
component->x += delta;
}
}
-- The filename gives this Actor its name
-- MyActor.lua
-- Create a new Entity to our Actor's spec
function Create (entity)
entity.AddComponent(SomeComponent:New(x))
end
-- Tick an Entity
function Tick (entity, delta)
local component = entity.GetComponent("SomeComponent")
component.x = component.x + delta
end