Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
MovieClip ... an example of use ? — Gideros Forum

MovieClip ... an example of use ?

GregBUGGregBUG Guru
edited December 2011 in Suggestions & requests
hi!

is possible to have little working example of using MovieClip ?
i want to replace all my sprite animation (with classic mode animation) with the use of MovieClip function
how to use them?

thanks and sorry for the request but (at least for me) the docs for MovieClip is not clear! :(


in the init function of my sprite i put
-- setup animations...
self.anim = {
Bitmap.new(pack:getTextureRegion("ucello1.png")),
Bitmap.new(pack:getTextureRegion("ucello2.png")),
Bitmap.new(pack:getTextureRegion("ucello3.png")),
Bitmap.new(pack:getTextureRegion("ucello4.png")),
}
mc = MovieClip.new{
{1, 1, self.anim[1]},
{2, 1, self.anim[2]},
{3, 1, self.anim[3]},
{4, 1, self.anim[4]},
{5, 1, self.anim[3]},
{6, 1, self.anim[2]},
{7, 1, self.anim[1]},
}
mc:setGotoAction(7, 1)

then in function birds:onEnterFrame()

i put
mc:play()

but no animation... :(

ciao
Gianluca.
TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
www.tntengine.com
+1 -1 (+5 / -1 )Share on Facebook
«1

Comments

  • atilimatilim Maintainer
    Your approach is correct but you need to change two things:

    1. MovieClip accepts start frame, end frame. So you should write:

    mc = MovieClip.new{
    {1, 2, self.anim[1]},
    {2, 3, self.anim[2]},
    {3, 4, self.anim[3]},
    {4, 5, self.anim[4]},
    {5, 6, self.anim[3]},
    {6, 7, self.anim[2]},
    {7, 8, self.anim[1]},
    }

    2. You need to call mc:play() once, not in enterFrame event.

    :ar!

    Likes: ilker

    +1 -1 (+1 / -0 )Share on Facebook
  • doh!!!

    now i'm at work!!! when i go home i'll try!!!

    thanks.!
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • gorkemgorkem Maintainer
    Did you know series #1: Our key performance indicator (KPI) for Gideros forum is to answer every question in less than 3 hours on average.
  • hi!

    i replaced the code of my animation using movieclip... it's very handy and is a more convenient way to setup animations... (no code to control frame animations!)

    in my elicopter code now i'm using...

    self.anim = {
    Bitmap.new(pack:getTextureRegion("eli1.png")),
    Bitmap.new(pack:getTextureRegion("eli2.png"))
    }

    local eliAnim = MovieClip.new{
    {1, 7, self.anim[1]},
    {8, 15, self.anim[2]}
    }
    eliAnim:setGotoAction(15, 1)

    self:addChild(eliAnim)
    eliAnim:play()

    and my elicopter fly!

    but if i want to speedup (at runtime) the animation (ex when the player accelerate) how can i do?

    can i use this method also for animate characters with no predefinited path ? (like the main player?)

    i can set it's position with eliAnim:setPosition(x, y)

    in theory movie clip is much more efficent for sprite animation than classic way (like "Texture pack" example) ?


    sorry for my continuous questions!

    thanks.
    Gianluca

    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • atilimatilim Maintainer
    Hi,

    Currently there is no way to set the animation speed. But you can prepare different animations for different speeds like:
    local eliAnim = MovieClip.new{
    {1, 7, self.anim[1]},
    {8, 15, self.anim[2]},
    {16, 18, self.anim[1]},
    {19, 21, self.anim[2]},
    }
    eliAnim:setGotoAction(15, 1)    --> frames 1-15: slow animation
    eliAnim:setGotoAction(21, 16)   --> frames 16-21: fast animation
     
    eliAnim:gotoAndPlay(1) --> play slow animation
    eliAnim:gotoAndPlay(16) --> play fast animation
    And you can position your MovieClip whereever you want. (running player, walking player, flying helicopter, etc)
  • That is basically the same problem that C*r*na had. I modified their moviecliplua file. Will look for tommorow. Controlling the animation speed is a crucial feature.
    +1 -1 (+2 / -0 )Share on Facebook
  • GregBUGGregBUG Guru
    edited December 2011
    I fully agree with MikeHart.
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
    +1 -1 (+2 / -0 )Share on Facebook
  • It would be also an interesting example of this class with the tool zoe, which exports a Flash animation MC. http://easeljs.com/zoe.html
  • I had a look at the movieclip feature in Gideros. It isn't a lua fiel like in C*r*na. So I can't extend that. They solution that atilim posted is currently the only one. Add repeating images to the movieclip.
  • atilimatilim Maintainer
    @ernesto exactly! Doing some tests and build an example with Zoë is in my list.
  • atilimatilim Maintainer
    @MikeHart

    I think MovieClip needs 2 main improvements:
    - adjusting speed
    - dispatching events when it stops or reaches a specified frame

    Can you think of another improvement?

  • >> MikeHart

    >> I think MovieClip needs 2 main improvements:
    >> - adjusting speed
    >> - dispatching events when it stops or reaches a specified frame

    yes i think it would be really useful B-)
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • Not sure if it can do that already, but besides the great enhancements you have mentioned, playing the animation backwards would be cool.
  • GregBUGGregBUG Guru
    edited December 2011
    it's not directly related with Movieclip, but why not implement in gideros runtime
    a DeltaTime? (yes i know i can implement my self but it is nice for a game sdk to have built in...)
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • atilimatilim Maintainer
    edited December 2011
    @MikeHart totally agree

    @GregBUG when the ENTER_FRAME event dispatches, the event object contains time and deltaTime:
    local function onEnterFrame(event)
      print(event.time, event.deltaTime)
    end
     
    stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)

    Likes: plamen, hosamred

    +1 -1 (+2 / -0 )Share on Facebook
  • oh! thanks! it's already there! :-\"

    sorry useless question ! :(
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • :P
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • gorkemgorkem Maintainer
    We're rewriting our documentation now, and hopefully you'll benefit from these docs.. :)
    +1 -1 (+3 / -0 )Share on Facebook
  • I wonder, how to check if the MovieClip is playing or not?
  • plamenplamen Member
    edited November 2012
    movieclip has event when it reaches stop command i use it a lot.
    current construction of movieclip has some limitations and flаws but it gives some unusual options. I'll give some example from my project. if you take a look to engines of the ships, the movieclip contains 2 sets of frames 1st for slow motion of the propellers and the second is for fast motion -->

    local prop_t={}
    for i=1,16 do
    prop_t[i]=Bitmap.new(TextureRegion.new(ventilator_texture, 16*(i-1), 0, 16, 64))
    prop_t[i]:setAnchorPoint(0.5,0.5)
    prop_t[i]:setScale(0.5)
    end

    self.propeller= MovieClip.new{
    {1, 1, prop_t[1]},
    {2, 2, prop_t[2]},
    {3, 3, prop_t[3]},
    {4, 4, prop_t[4]},
    {5, 5, prop_t[5]},
    {6, 6, prop_t[6]},
    {7, 7, prop_t[7]},
    {8, 8, prop_t[8]},
    {9, 9, prop_t[9]},
    {10, 10, prop_t[10]},
    {11, 11, prop_t[11]},
    {12, 12, prop_t[12]},
    {13, 13, prop_t[13]},
    {14, 14, prop_t[14]},
    {14, 15, prop_t[15]},
    {16, 16, prop_t[16]},
    }
    self.propeller:setStopAction(10)
    self.propeller:GotoAndPlay(1)
    self.propeller:addEventListener("complete", self.onMovieComplete,self)

    frames 1-10 are for slow motion and 11 to 16 are for fast motion
    when i need them to run fast i do:

    self.propeller:setStopAction(16)
    self.propeller:GotoAndPlay(11)

    i use event handler for my logic code to decide swapping the two sets
    Also this construction gives you the option to animate lots of parameters and do tweens. Its very flexible but some how not very intuitive. It just needs more examples and it will be fine. First i was shocked about how different is from other frameworks but after two month extensive use i love it.
    ventilator.png
    256 x 64 - 23K
  • plamenplamen Member
    edited November 2012
    Here is another example of propeller:

    local propeller_bmp = Bitmap.new(propeller_A_texture)
    propeller_bmp:setAnchorPoint(0.5,0.5 )
    self.propeller=MovieClip.new{
    {1, 100, propeller_bmp,{rotation={0,360,"linear"}}}
    }
    self.propeller:setGotoAction(100,2)

    This one just rotates single bitmap.
    propeller_a.png
    64 x 64 - 9K
  • john26john26 Maintainer
    Is there anything that MoveClip can do that GTween can't? GTween seems better to me as it merely moves/rotates existing sprites therefore providing a thin layer on top of sprites rather than introducing a new "object". Now that its possible to change the bitmap of a sprite, can't GTween do everything MovieClip can do?
  • MovieClip executes compiled C code. Perfect for like 200 instances... or 600 :>
  • Additionally to what @planem said, that MovieClip is more efficient, it also provides a frame based animation, where you can easily switch between different bitmaps.
  • Is there any method "resume" in MovieClip, it called play when the animation stops and do nothing when the animation plays? Or how can I do this?
  • @riyann68 as said by @ar2rsawseen and @plamen MovieClip is very efficient.
    My TNT Animator is based over it.

    maybe you can try it.

    Likes: riyann68

    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
    +1 -1 (+1 / -0 )Share on Facebook
  • @riyann68 you can use gotoAndPlay or gotoAndStop to go to specific action.

    And yes, try out the TNT Animator, it would really ease things up. ;)
  • atilimatilim Maintainer
    edited November 2012
    My TNT Animator is based over it.

    maybe you can try it.
    definitely you should! \m/

    Also @plamen's example is a great one. It's possible to put multiple animations into one MovieClip and separate them by using setStopAction function.
Sign In or Register to comment.