diff options
author | chai <chaifix@163.com> | 2019-03-25 23:46:59 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-03-25 23:46:59 +0800 |
commit | 03b3b8ae80559745f98ef94569b421adddeb441f (patch) | |
tree | 7bf46892fef7453d4c25172333bd4fbddb29ee16 /source/libs/asura-lib-framework/scripts | |
parent | 82956beb1fe17e1226327638c8ab22b5f5adfc1d (diff) |
*misc
Diffstat (limited to 'source/libs/asura-lib-framework/scripts')
-rw-r--r-- | source/libs/asura-lib-framework/scripts/component.lua | 6 | ||||
-rw-r--r-- | source/libs/asura-lib-framework/scripts/entity.lua (renamed from source/libs/asura-lib-framework/scripts/gameobject.lua) | 49 | ||||
-rw-r--r-- | source/libs/asura-lib-framework/scripts/filesystem/entity_loader.lua | 2 | ||||
-rw-r--r-- | source/libs/asura-lib-framework/scripts/graphics/animator.lua | 6 | ||||
-rw-r--r-- | source/libs/asura-lib-framework/scripts/graphics/particle_system.lua | 4 | ||||
-rw-r--r-- | source/libs/asura-lib-framework/scripts/scene.lua | 2 |
6 files changed, 34 insertions, 35 deletions
diff --git a/source/libs/asura-lib-framework/scripts/component.lua b/source/libs/asura-lib-framework/scripts/component.lua index 9306f3b..b560bd3 100644 --- a/source/libs/asura-lib-framework/scripts/component.lua +++ b/source/libs/asura-lib-framework/scripts/component.lua @@ -3,7 +3,7 @@ AsuraEngine.Component = AsuraEngine.Class("Component") local Component = AsuraEngine.Component -- Component要显示在inspector的变量 -Component.gameobject = AsuraEngine.Type.GameObject +Component.entity = AsuraEngine.Type.Entity function Component.Extend(cname) self.base(cname) @@ -11,8 +11,8 @@ function Component.Extend(cname) end -function Component:Ctor(gameobject) - self.gameobject = gameobject +function Component:Ctor(entity) + self.entity = entity end function Component:OnEvent(e) diff --git a/source/libs/asura-lib-framework/scripts/gameobject.lua b/source/libs/asura-lib-framework/scripts/entity.lua index a2d20ef..ea8e14d 100644 --- a/source/libs/asura-lib-framework/scripts/gameobject.lua +++ b/source/libs/asura-lib-framework/scripts/entity.lua @@ -1,22 +1,23 @@ -- -- 实体,作为scene中的实体存在。Scene中唯一管理的就是实体entity,游戏里的所有component都依附于entity存在,包括camera组件。 -- +module "AsuraEngine" require "transform" -AsuraEngine.GameObject = AsuraEngine.Asset.Extend("GameObject") +AsuraEngine.Entity = AsuraEngine.Asset.Extend("Entity") -local GameObject = AsuraEngine.GameObject +local Entity = AsuraEngine.Entity -function GameObject:Ctor() +function Entity:Ctor() self.transform = AsuraEngine.Transform.New() self.subentities = {} -- Extend node entities end -function GameObject:AddChild(gameobject) - table.insert(self.child, gameobject) +function Entity:AddChild(entity) + table.insert(self.child, entity) end -function GameObject:AddComponent(type, name) +function Entity:AddComponent(type, name) local cname = type if name == nil then cname = name @@ -25,21 +26,19 @@ function GameObject:AddComponent(type, name) self.components[cname] = compoennt end --- 根据组件名拿到组件 -function GameObject:GetComponent(name) +function Entity:GetComponent(name) return self.components[name] end --- 根据组件类型拿到组件 -function GameObject:GetComponentByType(tname) +function Entity:GetComponentByType(type) end -function GameObject:OnEnable() +function Entity:OnEnable() end -function GameObject:OnEvent(e) +function Entity:OnEvent(e) if self.components == nil or type(self.components) ~= "table" then AsuraEditor.LogError("") return @@ -51,7 +50,7 @@ function GameObject:OnEvent(e) end end -function GameObject:OnUpdate(dt) +function Entity:OnUpdate(dt) for name, component in self.components do if component.OnUpdate ~= nil then component:OnUpdate(dt) @@ -59,7 +58,7 @@ function GameObject:OnUpdate(dt) end end -function GameObject:OnRender() +function Entity:OnRender() for name, component in self.components do if component.OnRender ~= nil then component.OnRender() @@ -67,7 +66,7 @@ function GameObject:OnRender() end end -function GameObject:OnDisable() +function Entity:OnDisable() for name, component in self.components do if component.OnDisable ~= nil then component.OnDisable() @@ -75,41 +74,41 @@ function GameObject:OnDisable() end end -function GameObject:GetTrasform() +function Entity:GetTrasform() return self.transform end -function GameObject:GetPosition() +function Entity:GetPosition() end -function GameObject:GetScale() +function Entity:GetScale() end -function GameObject:GetRotation() +function Entity:GetRotation() end -function GameObject:SetTrasform(transform) +function Entity:SetTrasform(transform) end -function GameObject:SetPosition() +function Entity:SetPosition() end -function GameObject:SetScale() +function Entity:SetScale() end -function GameObject:SetRotation() +function Entity:SetRotation() end --写asset -function GameObject:ToAsset() +function Entity:ToAsset() end -return GameObject
\ No newline at end of file +return Entity
\ No newline at end of file diff --git a/source/libs/asura-lib-framework/scripts/filesystem/entity_loader.lua b/source/libs/asura-lib-framework/scripts/filesystem/entity_loader.lua index 57a890f..39ae0d9 100644 --- a/source/libs/asura-lib-framework/scripts/filesystem/entity_loader.lua +++ b/source/libs/asura-lib-framework/scripts/filesystem/entity_loader.lua @@ -1,4 +1,4 @@ -local loader = AsuraEngine.Loader.New("gameobject") +local loader = AsuraEngine.Loader.New("entity") function loader.OnLoad(asset) diff --git a/source/libs/asura-lib-framework/scripts/graphics/animator.lua b/source/libs/asura-lib-framework/scripts/graphics/animator.lua index c019dfa..fd2f979 100644 --- a/source/libs/asura-lib-framework/scripts/graphics/animator.lua +++ b/source/libs/asura-lib-framework/scripts/graphics/animator.lua @@ -8,9 +8,9 @@ local Animator = AsuraEngine.Animator Animator.spriteRenderer = AsuraEngine.Type.SpriteRenderer Animator.animation = AsuraEngine.Type.Animation -function Animator:Ctor(gameobject, animation) - self.base(gameobject) - self.spriteRenderer = gameobject:GetSpriteRenderer() +function Animator:Ctor(entity, animation) + self.base(entity) + self.spriteRenderer = entity:GetSpriteRenderer() self.animation = animation end diff --git a/source/libs/asura-lib-framework/scripts/graphics/particle_system.lua b/source/libs/asura-lib-framework/scripts/graphics/particle_system.lua index 8de3258..065a845 100644 --- a/source/libs/asura-lib-framework/scripts/graphics/particle_system.lua +++ b/source/libs/asura-lib-framework/scripts/graphics/particle_system.lua @@ -4,8 +4,8 @@ AsuraEngine.ParticleSystem = AsuraEngine.Component.Extend("ParticleSystem") local ParticleSystem = AsuraEngine.ParticleSystem -function ParticleSystem.Ctor(self, gameobject, def) - self.base(gameobject) +function ParticleSystem.Ctor(self, entity, def) + self.base(entity) self.spriteRenderer = AsuraEngine.SpriteRenderer.New() end diff --git a/source/libs/asura-lib-framework/scripts/scene.lua b/source/libs/asura-lib-framework/scripts/scene.lua index 3036ce1..11ac86c 100644 --- a/source/libs/asura-lib-framework/scripts/scene.lua +++ b/source/libs/asura-lib-framework/scripts/scene.lua @@ -6,7 +6,7 @@ AsuraEngine.Scene = AsuraEngine.Asset.Extend("Scene") local Scene = AsuraEngine.Scene function Scene.Ctor(self) - self.rootGameObjects = {} --当前场景的所有root gameobject + self.rootGameObjects = {} --当前场景的所有root entity self.super.Ctor(self) end |