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
Comments
use
Michael
Taking the example project GTween, if I change the code to this:
I will wait for your judgement . Thanks .
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.
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.
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
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,
Small question though, should this:
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)