Reputation: 623
How can i set framerate in a movieclip inside corona sdk? I have a normal movieclip but i want a slower animation. I cant find api documentation about movieclip.
Upvotes: 0
Views: 914
Reputation: 623
a way to improve @krs answer if you want pass a parameter:
local function callNextFrame(target)
target:nextFrame()
end
function play_anim( event )
local listener = function() return callNextFrame( event.target ) end
timer.performWithDelay(100,listener,24)
end
reference: http://docs.coronalabs.com/api/library/timer/performWithDelay.html
Upvotes: 1
Reputation: 3063
Movieclip is deprecated in favor of imageSheets and Sprites where you can have better control over the timing. There is a variant of movieclip.lua out there that lets you specify a delay, but it's an unsupported version.
Upvotes: 2
Reputation: 7390
You can use myAnim:nextFrame()
with the help of a timer
for this purpose. Try the following code:
local movieclip = require("movieclip")
local myAnim = movieclip.newAnim{"cube1.png", "cube2.png", "cube3.png", "cube4.png", "cube5.png", "cube6.png"}
myAnim.x = 160
myAnim.y = 240
localGroup:insert( myAnim )
For fast transition between frames, you can use:
local function callNextFrame()
myAnim:nextFrame()
end
timer.performWithDelay(10,callNextFrame,-1)
For slow transition between frames, you can use:
local function callNextFrame()
myAnim:nextFrame()
end
timer.performWithDelay(1000,callNextFrame,-1)
for further info, visit:
Keep coding.............. :)
Upvotes: 2