movieclip being a pain

I am sure that this is the easiest of them all, but for some reason, it seems its not my day today.

If I so much as add

local movieclip = require(“movieclip”)

the app breaks. It tells me that there is no movieclip.lu, movieclip.lua or movieclip.blu

so am I missing something here or is there an issue?

cheers,

Jayant C Varma [import]uid: 3826 topic_id: 3676 reply_id: 303676[/import]

is movieclip.lua in your folder? it’s not built into corona like “physics”, “sprite” is etc. it’s in the supplied example code

[import]uid: 6645 topic_id: 3676 reply_id: 11196[/import]

thanks jmp909, as I said, this might be resolved easily.

Since it is part of the API documentation, I presumed that this would be inbuilt like physics, and other stuff.

cheers,

Jayant C Varma [import]uid: 3826 topic_id: 3676 reply_id: 11202[/import]

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]

you can only have 1 of 2 frame rates, 30 or 60. adjust your code accordingly to cater for this.

or i guess you could use the clock to check the delta time between frames
http://www.8bitrocket.com/2008/4/8/Tutorial-Creating-an-Optimized-AS3-Game-Timer-Loop/ [import]uid: 6645 topic_id: 3676 reply_id: 11250[/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 :wink:

cheers,

Jayant C Varma [import]uid: 3826 topic_id: 3676 reply_id: 17715[/import]

Hi Jayant,

You’re right it didn’t work with multiple anims :slight_smile:

But you did point me in the right direction, I made a few changes to the movieclip.lua module:

  1. Change the play function to accept an additional speed argument:
    [lua]function g:play( fps, params )[/lua]

  2. 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]

  3. 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]

  4. 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]

Hi I am having a little trouble getting your solution to work, when i do,

object:play( 30 )   

I get an error saying ‘params’ is undefined, if I try to call it as

object:play(30 { startFrame=1, endFrame=31, loop=1, remove=false })  

I get the following error

“attempt to index local ‘params’ (a number value)”

what am I doing wrong, thanks!

EDIT:

Nevermind, my second call worked, I just had an error somewhere else [import]uid: 17878 topic_id: 3676 reply_id: 18955[/import]

thank you so much, bedhouin!

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]