- Изменено
[Lua - Corona] How to property play / stop animation
- Изменено
Hello, i'm new at Spine, i created a animation for my game, but i hard to control animation.
Here i my weird animation:
Here i my hopefull display: (GIF, i export from spine, but i dont why it not repeat)
Code used to play and stop animation, i copied from Spine example
local function playAnim(event)
local currentTime = event.time / 1000
local delta = currentTime - _lastTime
_lastTime = currentTime
local skeleton = M.skeleton;
local state = M.state;
state:update(delta)
state:apply(skeleton)
skeleton:updateWorldTransform();
end;
function M.roll(point)
M.tops = ResultDb.getResult(point);
Runtime:addEventListener("enterFrame", playAnim);
end;
local function onRollComplete(trackIndex, event)
updateResourceName();
Runtime:removeEventListener("enterFrame", playAnim);
end;
function M.load()
local spineData = Skeleton.load("res/game/dice/skeleton", centerX + 120, centerY - 200, 0.5, "shake");
M.skeleton = spineData.skeleton;
M.state = spineData.state;
---
End roll event
M.state.onEvent = onRollComplete;
M.skeleton.group.rotation = 175;
end;
Here is images about frame 0, 30, 40
If i use setAnimationByName with loop = false, it's alway show last frame and dont play animation.
If i use setAnimationByName with loop = true, it's display like weird.... and i dont know how to stop at last frame to show dice result.
If i call Runtime:removeEventListener("enterFrame", playAnim); with loop = true, it turn to frame 0 in the end animation
Anyone can give me some advice... i tried to search all day but i can't improve my animation
I'm sorry, your images and video don't work. Could you maybe modify the Corona example in our runtime repository to show the issue? Simply modify the main.lua
file.
badlogic написалI'm sorry, your images and video don't work. Could you maybe modify the Corona example in our runtime repository to show the issue? Simply modify the
main.lua
file.
So sorry, i edited Video and Image links
Does this code actually calculate in seconds?
local currentTime = event.time / 1000
local delta = currentTime - _lastTime
_lastTime = currentTime
It's usually easiest to boil down a problem like this by creating a simple main.lua that just does the animation. If that doesn't work, then please send me your Spine project to contact@esotericsoftware.com.