espace Posted May 7, 2018 Share Posted May 7, 2018 hi, Assuming i have several tweens for example : var tween_a; var tween_b; var tween_c; var tween_d .... how to cancel for example all the tweens except the tween_c is it possible in a single line code ? Link to comment Share on other sites More sharing options...
Fenopiù Posted May 7, 2018 Share Posted May 7, 2018 If you put them in a group, you can destroy any child except one. Link to comment Share on other sites More sharing options...
espace Posted May 7, 2018 Author Share Posted May 7, 2018 sorry but how do you do that ? Link to comment Share on other sites More sharing options...
Fenopiù Posted May 8, 2018 Share Posted May 8, 2018 Or you can simply create your "tweens array" and call a kill to every tween in the array except the one you want to let alive. Link to comment Share on other sites More sharing options...
espace Posted June 8, 2018 Author Share Posted June 8, 2018 thanks with my library and your advice it's done. //utils.js var wait = ()=> (callback, duration) { setTimeout(callback, duration); } //config.js var p = { o: cloud, //object t: 1000, //time d: 5000, //delay a: 1, //alpha e: Phaser.Easing.Elastic.Out //Easing //r: 85, //rotation //sx :2, //scalex //sy :4, //scaley //dx :400, //displacementx //dy :200, //displacementy //y: true //yoyo, //dyo :800, //delay yoyo } //utils.js var _tr = (game, p) => { //transition,game,parameter this.game = game if (p.e === null) { p.e = Phaser.Easing.Linear.None } this.s = () => { // start tween if (p.a !== null) { // alpha this.tw = game.add.tween(p.o).to({ alpha: p.a }, p.t, p.e, true, p.d); } if (p.r !== null) { //rotation this.tw = game.add.tween(p.o).to({ angle: p.r }, p.t, p.e, true, p.d); } if (p.sx !== null) { //scale this.tw = game.add.tween(p.o.scale).to({ x: p.sx, y: p.sy }, p.t, p.e, true, p.d); } if (p.dx !== null) { //displacement this.tw = game.add.tween(p.o).to({ x: p.dx, y: p.dy }, p.t, p.e, true, p.d); } } this.c = (callback, time) => { //complete let time_adapted = p.d + p.t + time wait(callback, time_adapted) } this.y = () => { //yoyo if (p.y !== null) { this.tw(true, p.dyo) } } this.p=()=>{ //pause this.tw.pause() } this.r=()=>{ //resume this.tw.resume() } this.s=()=>{ //stop this.tw.stop() } this.s() //start the tween } //main.js var tw={} tw[0] = new _tr(game,p) tw[1] = new _tr(game,p) //stop all expect n°1 for (i = 0; i < tw.length; i++) { if(i != 1){ tw[i].s() } } Link to comment Share on other sites More sharing options...
Recommended Posts