feat: add signal on some frames
This commit is contained in:
parent
cf7be0cb55
commit
eabd1a3a8c
1 changed files with 20 additions and 0 deletions
|
@ -66,6 +66,7 @@ function Animator:update(dt)
|
|||
self:sendCallback()
|
||||
else
|
||||
self.frame = self.frame + 1
|
||||
self:sendFrameSignal()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -139,6 +140,25 @@ function Animator:sendCallback()
|
|||
end
|
||||
end
|
||||
|
||||
function Animator:sendFrameSignal()
|
||||
if (self.animationData.signal ~= nil) then
|
||||
if (type(self.animationData.signal[1]) ~= "table") then
|
||||
self:trySendSignal(self:getRelativeFrame(), self.animationData.signal)
|
||||
else
|
||||
for _, signal in ipairs(self.animationData.signal) do
|
||||
self:trySendSignal(self:getRelativeFrame(), signal)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Animator:trySendSignal(frame, signal)
|
||||
print(signal[2], frame, signal[1])
|
||||
if (signal[1] == frame) and (self.actor ~= nil) and (self.actor.receiveFrameSignal ~= nil) then
|
||||
self.actor:receiveFrameSignal(signal[2])
|
||||
end
|
||||
end
|
||||
|
||||
-- DRAW FUNCTIONS
|
||||
-- Draw animations using these functions
|
||||
|
||||
|
|
Loading…
Reference in a new issue