Tween with negative delay?

Hi guys

Just wondering whether there is a way to tween something with a negative delay?

I’ve been using TweenMax with Flash and you can set a negative delay, which basically makes whatever property you’re tweening start before the tween begins.

If I don’t use a negative delay and the player enters a level, then they will see a pause before the property gets tweened (which is what I want to avoid).

Thank you for any help :slight_smile:

Do you use composer?

If so I guess you could create the the object on scene creation and start the transition on scene:show().

-- "scene:create()" function scene:create( event ) local sceneGroup = self.view -- Initialize the scene here. -- Example: add display objects to "sceneGroup", add touch listeners, etc. end

Just trying to get my head around what you’re asking … you have an object at, say, x=0, and you want to transition/tween it, but you want that transition to start at x=100 and go to x=200 … something like that?  I would guess that right now, the object is jumping from its current position at x=0 to x=100, then smoothly transitioning to x=200.

So the negative delay is really just a flag to say “first move the object to the start position”?

If so, I wonder if you could hack it with the transition/onStart listener?  (can’t find what is in the onStart event, but maybe you could pass it some kind of flag)

Hi Guys

Thank you again for you help!

Sorry for the confusion. I’ll try to explain this with a basic example …

I have to Boxes

I want to move both boxes from x0 to x100 (and back to x0) over 2 seconds (So the boxes take 1s to get there and 1s to get back)

However, I want Box1 to already be halfway to x100 when the scene starts

In this case I would use a negative delay of -500 (500 milliseconds) which tells the tween that it’s effectively started already and the tween works out the position Box1 should be at.

There are other ways to do this, but much harder to setup. This way I can use a continuous loop.

I use this same technique in TweenMax.

Hope this makes it a little clearer :slight_smile:

Do you use composer?

If so I guess you could create the the object on scene creation and start the transition on scene:show().

-- "scene:create()" function scene:create( event ) local sceneGroup = self.view -- Initialize the scene here. -- Example: add display objects to "sceneGroup", add touch listeners, etc. end

Just trying to get my head around what you’re asking … you have an object at, say, x=0, and you want to transition/tween it, but you want that transition to start at x=100 and go to x=200 … something like that?  I would guess that right now, the object is jumping from its current position at x=0 to x=100, then smoothly transitioning to x=200.

So the negative delay is really just a flag to say “first move the object to the start position”?

If so, I wonder if you could hack it with the transition/onStart listener?  (can’t find what is in the onStart event, but maybe you could pass it some kind of flag)

Hi Guys

Thank you again for you help!

Sorry for the confusion. I’ll try to explain this with a basic example …

I have to Boxes

I want to move both boxes from x0 to x100 (and back to x0) over 2 seconds (So the boxes take 1s to get there and 1s to get back)

However, I want Box1 to already be halfway to x100 when the scene starts

In this case I would use a negative delay of -500 (500 milliseconds) which tells the tween that it’s effectively started already and the tween works out the position Box1 should be at.

There are other ways to do this, but much harder to setup. This way I can use a continuous loop.

I use this same technique in TweenMax.

Hope this makes it a little clearer :slight_smile: