refactor MapBehavior:update
This commit is contained in:
parent
601766d5e8
commit
6faf7f1c1d
@ -63,17 +63,13 @@ function mapBehavior:update(dt)
|
||||
if fraction >= 1 then -- анимация перемещена завершена
|
||||
self.position = self.runTarget
|
||||
if not self.path:is_empty() then -- еще есть, куда бежать
|
||||
self:runTo(self.path:peek_front())
|
||||
self.path:pop_front()
|
||||
self:runTo(self.path:pop_front())
|
||||
else -- мы добежали до финальной цели
|
||||
self.owner:try(Tree.behaviors.sprite, function(sprite)
|
||||
sprite:loop("idle")
|
||||
end)
|
||||
self.runTarget = nil
|
||||
if self.animationNode then
|
||||
self.animationNode:finish()
|
||||
self.onWalkEnd = nil
|
||||
end
|
||||
if self.animationNode then self.animationNode:finish() end
|
||||
end
|
||||
else -- анимация перемещения не завершена
|
||||
self.displayedPosition = utils.lerp(self.position, self.runTarget, fraction) -- линейный интерполятор
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user