31 lines
883 B
Lua
31 lines
883 B
Lua
local BattleNumberComp = class("BattleNumberComp", LuaComponent)
|
|
|
|
function BattleNumberComp:init()
|
|
local uiMap = self.baseObject:genAllChildren()
|
|
self.animator = self.baseObject:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR)
|
|
self.effectText = uiMap["battle_number.text_number"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT)
|
|
self.time = 0
|
|
end
|
|
|
|
function BattleNumberComp:showEffectNumber(num, x, y)
|
|
self.effectText.text = tostring(num)
|
|
self.baseObject:setLocalPosition(x, y, 0)
|
|
self.animator:Play("battle_number_move", -1, 0)
|
|
self.time = 1.367
|
|
end
|
|
|
|
function BattleNumberComp:setEnabled(enabled)
|
|
local scale = enabled and 1 or 0
|
|
self.baseObject:setLocalScale(scale, scale, scale)
|
|
self.animator.enabled = enabled
|
|
end
|
|
|
|
function BattleNumberComp:getDuration()
|
|
return self.time
|
|
end
|
|
|
|
function BattleNumberComp:tick(dt)
|
|
self.time = self.time - dt
|
|
end
|
|
|
|
return BattleNumberComp |