Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
MovieClip, is there another way to assign value to its table? — Gideros Forum

MovieClip, is there another way to assign value to its table?

monkrymonkry Member
edited December 2012 in General questions
I hope my question isn't wrong...
I'm newbie in Gideros (and also, actually, in programming), and... nice to meet you :)

So, you can do this with usual table (the code is just example):
    local texture = Texture.new("chuchuchu.png")
    local frame = {}
    for i=0, 4 do
        frame[i+1] = Bitmap.new(TextureRegion.new(texture, i*100, 0, 100, texture:getHeight()))
    end
Is there a way to assign value to MovieClip table that way?
If I have many charaters and the number of sprite's frame is varying, then I have to assign each frame to MovieClip.

I've tried this:
    local mc = MovieClip.new{
        {1, duration, frame[1]},
    }
    for i=2, 10 do
        mc[i] = {duration*(i-1)+1, duration*i, frame[i]}
    end
when I printed #mc, it printed 10, but the animation didn't work.

If you have a way, please tell me. And if there's no way to do something like that, please also tell me :)

Comments

  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    @monkry what MovieClip accepts as a parameter is a simple table with your frames and image value.
    So you can simply generate needed table and pass it to MovieClip constructor
    --generate table with frames and durations
    local frames = {}
    frames[1] = {1, duration, frame[1]}
    for i=2, 10 do
        frames[i] = {duration*(i-1)+1, duration*i, frame[i]}
    end
     
    --pass it to movie clip constructor
    local mc = MovieClip.new(frames)
    I think that should work

    Likes: monkry

    +1 -1 (+1 / -0 )Share on Facebook
  • monkrymonkry Member
    edited December 2012
    All hail! It works!
    Thank you, thank you so much for your help! :'D

    Actually, At first I was kinda pessimist seeing your answer, because I've tried something like that (passing table as its param) and it was failed. But I've done the table wrong...

    Again, thank you so much for your help! :D

    Likes: ar2rsawseen

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.