Got the movie Clip to work, but then… it is so FAST that it is hardly animation, it looks like animation on steroids, its too fast, how can I set the speed of the movie clip?
I am sure that is also obvious and easy, but…
*EDIT* I editied the movieclip.lua and added a new param, animSpeed this is used to slow down the animation.
Added two new local variables
local animSpeed=100 --Default Speed
local currentCounter=0
and modified the function header.
function newAnim (speed, imageTable)
and in the function set the animSpeed to the speed passed
animSpeed = speed
and then changed the enterFrame as
function g:enterFrame( event )
if currentCounter==0 then
self:repeatFunction( event )
currentCounter = animSpeed
end
currentCounter=currentCounter - 1
end
that’s it, it works for me…
But there has to be an easier way, if anyone knows, please let me know.
cheers,
Jayant C Varma [import]uid: 3826 topic_id: 3676 reply_id: 11207[/import]
Hi. I had a similar problem with Movieclip. I think it conforms to the FPS setting under config.lua? If your project is set to 30FPS, your movieclip will go at that speed. At 60fps, twice as fast. [import]uid: 11024 topic_id: 3676 reply_id: 11246[/import]
@jayant: Great fix. Works perfectly. Ansca should use your modification in future updates of movieclip resource file. [import]uid: 11393 topic_id: 3676 reply_id: 17709[/import]
@bedhouin,
I guess there are some issues that come up, specially when you use multiple instances of movieclips. My solutions is not perfect, it works randomly. I find that the solution in BeeBeGames class for animation works best.
However, if my solution works for you, thank you, I do not mind the few seconds of fame
cheers,
Jayant C Varma [import]uid: 3826 topic_id: 3676 reply_id: 17715[/import]
But you did point me in the right direction, I made a few changes to the movieclip.lua module:
Change the play function to accept an additional speed argument:
[lua]function g:play( fps, params )[/lua]
Add this code immediately to the top of function play:
[lua]animFrames[0] = {} – Uses redundant index of zero to store play speed info for each object as it is created
animFrames[0].counter = 0
if fps then
animFrames[0].fps = 30 / fps – Assumes framerate running at 30fps
else
animFrames[0].fps = 2 – Default to every 2nd frame so 15 fps
end[/lua]
Modify g:enterFrame function:
[lua]animFrames[0].counter = animFrames[0].counter + 1 – Increment frame counter
if animFrames[0].counter >= animFrames[0].fps then – If we are ready to show next frame
self:repeatFunction( event )
animFrames[0].counter = 0 – Reset frame counter
end[/lua]
Call the animation with fps speed as first argument:
[lua]object:play( 30 ) – plays at 30fps
object:play( 15 ) – plays at 15fps[/lua]
This seems to work as frame speed and counter information is stored independently within each object. It’s possible to shift the table creation code from function play() to function newAnim(). I thought it would be easier to change the speed of the movie after it was created.
I’m sure there it can be improved but it seems to work well enough. [import]uid: 11393 topic_id: 3676 reply_id: 17812[/import]
I was doing it the worst way possible, creating the tables with repeated names for it to work. was really a pain when I needed to change the speed and had to remove the previous object and create a new one… now I can just change the speed =)
this should be implemented by default! [import]uid: 125498 topic_id: 3676 reply_id: 89303[/import]