Make Tween.get multiple targets
See original GitHub issueIt’s nice to have multiple targets in Tween.get to reduce the number of lines in code:
var target_a = new createjs.Shape();
var target_b = new createjs.Shape();
var targets = [target_a, target_b];
createjs.Tween.get(targets, {loop:true}, true)
.to({x: 300, y: 300}, 3000);
// also support the following:
createjs.Tween.get(target_a, {loop:true}, true)
.to({x: 300, y: 300}, 3000);
createjs.Tween.get(target_b, {loop:true}, true)
.to({x: 300, y: 300}, 3000);
Issue Analytics
- State:
- Created 10 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Best way to apply a modifier tween on multiple targets? - GSAP
Greetings! I'm using Blakes clever method of using a mouse object to update a modifier function ( See the Pen ...
Read more >TweenJS multiple tweens on multiple targets - Stack Overflow
The idea is to tween myimage inside the container to a new x and y position. This should be followed by rotating the...
Read more >Multitarget tween with different parameters - Phaser 3
Hello, let's say I have a tween for a large array of targets. Is there a way to set slightly different parameters for...
Read more >Adding tween targets to existing tween - Phaser 3
However, this seems inefficient as I know that you can have one tween with multiple targets, so having loads of tweens that all...
Read more >TweenJS v1.0.0 API Documentation : Tween - CreateJS
Multiple tweens can share a target, however if they affect the same properties there could be unexpected behaviour. To stop all tweens on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
And of course, you could use Timeline, which is specifically designed for coordinating parallel tweens.
@zur4ik If the tweens have the same duration, you can just create two separate ones, but only add a
call()
to one of them (the longer). Tweens are deterministic, so they should play at the duration specified, no matter what the CPU performance is.If you have complex tween chains, and don’t want to determine the length, you could just have them both call the same method, and ensure both have finished before moving on:
Obviously that is just an example, but those are probably your best options. There is no framework in TweenJS to manage multiple objects with a single tween, so you will have to come up with something that works for your case.
Cheers,