Quick Links: Gideros Home | Download Gideros | Developer Guide
Understanding MovieClips- question!
  • stetso +1 -1
    Hello, here I go with another annoying question.

    I am trying to chain the movement of some elements together with MovieClip but even in a simple case it does not do what I want. Since there is not :playBackward() function (which would be very handy), I simply have another MovieClip with the reverse coordinates. But somehow it does not do what I want. Can anyone help me understand this problem? Here is a simple code snippet that is already not working:
    local state = "up"
    local p1 = Pixel.new(0xF17370)
    local mc1 = MovieClip.new{ -- move the square down
    {1,50,p1,{ y= {p1:getY(), 80, "inOutBack"}}}
    local mc2 = MovieClip.new{ -- move it up again
    {1,50,p1,{ y= {p1:getY(), 20, "inOutBack"}}}
    stage:addEventListener(Event.KEY_DOWN, function(ev)
    if ev.keyCode == KeyCode.X then
    if state == "up" then
    elseif state == "down" then
    state = "up"

    Hope for some insights as I find the general idea of MovieClips pretty nice but somehow have trouble getting them to work. All the examples floating around are mainly for frame-animations but here I am interested in the tweening functionality :-)

    Thanks in advance!
  • keszegh +1 -1 (+1 / -0 )
    Member Accepted Answer
    @stetso, the problem is that when you initialize the mc then p1:getY() is 20 for both mc1 and mc2 and so in mc2 nothing happens (tween from 20 to 20).
    so your error is that you regard the mc inits as functions whereas they are stored as values.

    so if you change p1:getY() to 20 and the second occurrence to 80, it will work fine.

    Likes: stetso

  • keszegh +1 -1
    i agree that a playReverse function would be more than handy, i also have to setup reverse mc's for all my frame-by-frame animations, which is a hassle.
  • stetso +1 -1 (+1 / -0 )
    @keszegh Ah, thank you, that was it. Should have probably tried that myself but it didnt even cross my mind that this was the problem. TIL #:-S

    Maybe we can persuade @hgy29 or @john26 to look into implementing a reverse function. I have seen a few other comments in the forum looking for something like that. Although I dont know the complexity involved... O:-)

    Likes: antix

  • antixantix +1 -1
    MovieClip needs a complete overhaul I think. It makes Bitmaps for every frame of animation which is really wasteful of RAM I think. A system similar that uses TextureRegions would be more efficient.
    Check out my DevBlog, my GitHub, and my games Falling Animals | Breaky Wall | Exetor
  • hgy29hgy29 +1 -1 (+2 / -0 )
    @stetso: acknowledged, I'll see what I can do.
    @antix: that's not quite true, MovieClip acts on sprites only, the coder is responsible for creating the sprites. MovieClip is more a tweening system than a way to display animations I would say, despite its name.
  • stetso +1 -1
    @hgy26 awesome, thanks!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook Sign In with OpenID

In this Discussion

Top Posters