espace Posted June 25, 2018 Share Posted June 25, 2018 hi, i would use tween with an object parameter...how do you do ? function create() { var sprite = game.add.sprite(0, 0, 'phaser'); var config={ properties : { sprite, x:100, } duration : 1000, ease : Phaser.Linear.none, autoStart : true, delay:10, repeat : 0, yoyo:false } game.add.tween(config) } Link to comment Share on other sites More sharing options...
espace Posted June 26, 2018 Author Share Posted June 26, 2018 Nobody ? Link to comment Share on other sites More sharing options...
onlycape Posted June 27, 2018 Share Posted June 27, 2018 Hi @espace, I think that directly is not possible. But you can make your own wrapper function for "game.add.tween". Here a simple wrapper ( http://phaser.io/sandbox/BFoPWrWT ) : // Function to wrap game.add.tween function tweenWrapper(obj){ game.add.tween(obj.target).to(obj.properties,obj.duration,obj.ease,obj.autoStart,obj.delay,obj.repeat,obj.yoyo); } function create() { var sprite = game.add.sprite(0, 0, 'phaser'); var config={ target: sprite, properties : { y:150, x:100, }, duration : 1000, ease : Phaser.Linear, autoStart : true, delay:10, repeat : 0, yoyo:false }; tweenWrapper(config); } Regards. espace 1 Link to comment Share on other sites More sharing options...
espace Posted June 28, 2018 Author Share Posted June 28, 2018 thanks, in fact i yet use a similar snippet ? var tw=[]; var _tw //pseudo prototype var parameter ={ e: Phaser.Easing.Bounce.Out, i: 0, //number repeat y: true, //yoyo a: 0, // alpha t: 500, //time d:100, // delay r: 45, //rotation dx:100, //distance dy:200, sx:1, //scale sy:1, } _tw = (p,n) => { //parameter,number if (p.e == null) { p.e = Phaser.Easing.Linear.None } if (p.i == null) { p.i = 0 } if (p.y == null) { p.y = false } if (p.a != null) { // alpha tw[n]=game.add.tween(p.o).to({ alpha: p.a }, p.t, p.e, true, p.d, p.i, p.y); } if (p.r != null) { //rotation tw[n] = game.add.tween(p.o).to({ angle: p.r }, p.t, p.e, true, p.d, p.i, p.y); } if (p.sx != null) { //scale tw[n]= game.add.tween(p.o.scale).to({ x: p.sx, y: p.sy }, p.t, p.e, true, p.d, p.i, p.y); } if (p.dx != null) { //displacement tw[n] = game.add.tween(p.o).to({ x: p.dx, y: p.dy }, p.t, p.e, true, p.d, p.i, p.y); } tw[n].c = () => { if (p.c != null) { let time_adapted = p.d + p.t + p.ctime wait(p.callback, time_adapted) } } tw[n].p = () => { //pause tw[n].pause() } tw[n].r = () => { //resume tw[n].resume() } } _tw(parameter,0) Link to comment Share on other sites More sharing options...
Recommended Posts