Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Movie Clips vs GTween — Gideros Forum

Movie Clips vs GTween

CarolineCaroline Guru
edited January 2012 in General questions
I've been trying to understand the difference between Movie Clips and GTweens.

I have had no success in getting a Movie Clip to work. If I do this example from the documentation:
local mc = MovieClip.new{{1, 100, dogSprite, {x = {0, 200, "linear"}}}}
then my dogSprite just disappears. (Btw, if I leave out the starting { and ending }, then the player crashes)

GTweens allow rotation, which Movie Clips don't, which really pushes Movie Clips out of the door for me.

However, I am having trouble with this code:
function playButtonOnMouseDown(event)	
	if playButton:hitTestPoint(event.x, event.y) then
		local tween1 = GTween.new(dogSprite, 2, {x = 400, y = 20})
		local tween2 = GTween.new(dogSprite, 2, {x = 100, y = 200})
		local tween3 = GTween.new(dogSprite, 2, {x = 50, y = 50})
		tween1.paused = true
		tween1.nextTween = tween2
		tween2.paused = true
		tween2.nextTween = tween3
		tween3.paused = true
	end
end
I have tried various configurations of this, and this version I wouldn't have thought would run at all, because everything is paused. I have a play button, and the first time it runs tween1, then 2, then 3. After that, when I press the play button, the tweens play at random, I assume because of timings.

So my question is

1. Can I set up a GTween that won't fire straight away?

2. Why doesn't the paused for tween2 and 3 get reset on the next onMouseDown event, so that it works correctly again? If I add
tween3.onComplete = function() tween2.paused = true tween3.paused = true end
the tweens are still random on the next playButtonOnMouseDown.

3. Should I be using Movie Clips? If I succeed in successfully chaining GTweens together, is it as efficient as using Movie Clips? (Will Movie Clips eventually support rotation?)

4. Why doesn't the Movie Clip example work?

Thanks :)

Likes: Yan

+1 -1 (+1 / -0 )Share on Facebook

Comments

  • Hi Caroline,

    use
    yourTween:setPaused(true/false)
    I see the usage of a movieclip more for the animation (Chnage of images). To change its position/rotation/alpha values, I would then use a tween with it.

    Michael
  • But you are right, it would be great if it can support rotation as well.
  • For me it works:
    local sprite = Bitmap.new(Texture.new("bird_black_01.png"))
    local mc = MovieClip.new{{1, 100, sprite, {x = {0, 200, "linear"}}}}
    stage:addChild(mc)
  • CarolineCaroline Guru
    edited January 2012
    Hi Caroline,
    use
    yourTween:setPaused(true/false)
    I replaced tween2.paused = true with tween2:setPaused(true), but the same thing happens. Isn't setPaused(true) the same thing as .paused = true?
    I see the usage of a movieclip more for the animation (Chnage of images). To change its position/rotation/alpha values, I would then use a tween with it.
    Oh, I see - like frame by frame as opposed to properties animation.
  • For me it works:
    local sprite = Bitmap.new(Texture.new("bird_black_01.png"))
    local mc = MovieClip.new{{1, 100, sprite, {x = {0, 200, "linear"}}}}
    stage:addChild(mc)
    :) - Thank you - I was using it wrong. It does work for me.
  • I can't get a tween to pause at all :(

    Taking the example project GTween, if I change the code to this:
    boxTween = GTween.new(sprite, 2, {x = 240}, {delay = 0.2, ease = easing.outBounce, repeatCount = -1, reflect = false})
    boxTween:setPaused(true)
    the box still bounces for ever.


  • MikeHartMikeHart Guru
    edited January 2012
    Mmmh, you are right. It seems it depends when it is called. I will do more tests.
  • I felt that setting {paused = true} when setting up the GTween.new should have worked.

    I will wait for your judgement :). Thanks :).
  • Don't wait to long. :(

    I can't pause them right after creation. If I pause them randomly inside an ENTER_FRAME event, it works. I don't get it, this is more than weird.
  • Should I bug report it?

    I think I can get around it, by creating tables that aren't tweens with the values, and then doing a GTween.new(tablevalue) at the point that I need to run it. I haven't tried that yet, because I'm not confident in lua tables, but it seems logical.

    As long as I can pause it in the middle of a tween, it should be OK.
  • atilimatilim Maintainer
    edited January 2012
    Hi,

    If you set {autoPlay = false} while creating, the tween starts paused.

    But calling setPaused(true) just after creating the tween should work also. I'll also check the original GTween's (http://gskinner.com/libraries/gtween/) behaviour about this issue.

    Also MovieClip supports
    - "x"
    - "y"
    - "rotation" -> just realized this is not mentioned in the reference manual :)
    - "scale"
    - "scaleX"
    - "scaleY"
    - "alpha"

    Likes: gorkem

    +1 -1 (+1 / -0 )Share on Facebook
  • atilimatilim Maintainer
    edited January 2012
    And here is the correct way to chain tweens:
    local tween1 = GTween.new(sprite, 1, {x = 240}, {})
    local tween2 = GTween.new(sprite, 1, {y = 100}, {autoPlay = false})
    local tween3 = GTween.new(sprite, 1, {alpha = 0}, {autoPlay = false})
    tween1.nextTween = tween2
    tween2.nextTween = tween3
    Also this is same:
    local tween3 = GTween.new(sprite, 1, {alpha = 0}, {autoPlay = false})
    local tween2 = GTween.new(sprite, 1, {y = 100}, {autoPlay = false, nextTween = tween3})
    local tween1 = GTween.new(sprite, 1, {x = 240}, {nextTween = tween2})

  • If you set {autoPlay = false} while creating, the tween starts paused.
    Doh - I had been trying that one, but was using "autoplay" instead of "autoPlay". Thankyou!
    Also MovieClip supports ...
    - "rotation"
    Brilliant :) - I'll experiment with that one too.
  • atilimatilim Maintainer
    edited January 2012
    Hi all,

    I've fixed a small bug about calling setPaused(true) just after the creation of the GTween object. Can you please update your gtween.lua from https://github.com/gideros/GTween

    Thanks,
  • That works :) - thanks.

    Small question though, should this:
    local tween3 = GTween.new(dogSprite, 2, {x = 50, y = 50}, {paused=true})
    be the same as:
    local tween3 = GTween.new(dogSprite, 2, {x = 50, y = 50})
    tween3:setPaused(true)
    ?


  • atilimatilim Maintainer
    Not same according to the original GTween. {autoPlay = false} is the official correct way.
  • Actually, if Movieclip supported onComplete handlers, wouldn't they be able to replace GTween totally? And as they are not LUA but native code, the speed of execution would be better. Just a thought.
  • atilimatilim Maintainer
    I agree. They have many features in common.

    MovieClips are designed to be static. You construct a movie clip animation then use again and again without changing it. GTween is more dynamic. You create a tween on demand, it plays and then garbage collected. As you said, after onComplete handlers are implemented, it seems MovieClips will be able to do everything that GTween does. (And, as you said, MovieClips are native and faster to execute)
Sign In or Register to comment.