espace Posted November 15, 2016 Share Posted November 15, 2016 hi, i'm searching to use the delay of a tween and also have the possibility to cancel this tween. But that don't work, the tween is still here and the lock function works... have you an idea ? this.tween=game.add.tween(background.cursor_player.scale).to({x:3},850,Phaser.Easing.Bounce.In,true,0) this.tween.onComplete.add(this.lock,this) this.lock=function(){ } game.time.events.add(100,this.tween(stop),this) Link to comment Share on other sites More sharing options...
drhayes Posted November 15, 2016 Share Posted November 15, 2016 That syntax doesn't make sense. Did you mean this? game.time.events.add(100, this.tween.stop, this.tween); Link to comment Share on other sites More sharing options...
nazimboudeffa Posted November 15, 2016 Share Posted November 15, 2016 something like works i think var myTween ... myTween = game.add.tween( ... ) myTween.stop() Link to comment Share on other sites More sharing options...
espace Posted November 15, 2016 Author Share Posted November 15, 2016 hi, i have tested both your solutions but that don't work. i make a jsfiddle about that. it"s maybe more simpler to understand like this. https://jsfiddle.net/espace3d/vsouexg4/ Circle = function (game,Group) { Phaser.Sprite.call(this, game, 200, 200, 'circle'); this.Group=Group Group.add(this); }; Circle = function (game,Group) { Phaser.Sprite.call(this, game, 200, 200, 'circle'); this.Group=Group Group.add(this); }; Circle.prototype = Object.create(Phaser.Sprite.prototype); Circle.prototype.constructor = Circle; Circle.prototype.hide = function() { this.tween=game.add.tween(this).to({x:400},1000,Phaser.Easing.Linear.None,true) this.tween.onComplete.add(change_visibility,this) //HERE THE PROBLEM //normally i must see that the circle is not visible //because time=1000 > 500 on the function next //if i uncomment this line my circle is effectively not visible game.time.events.add(1000,this.tween.stop); function change_visibility(){ game.time.events.add(500, next, this); } function next(){ this.visible=false } }; var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload,create: create, update: update, render: render }); var cercle var group0 function preload() { game.load.image('circle', 'https://s13.postimg.org/xjhlzmiev/disc_png.png'); }; function create() { group0=game.add.group() cercle=new Circle(game,group0); cercle.hide() }; function update() { }; function render() { } Link to comment Share on other sites More sharing options...
espace Posted November 16, 2016 Author Share Posted November 16, 2016 Solved i have forgot that my time transition is 1000 so i must put stop tween at 3000 to see my circle not visible. Link to comment Share on other sites More sharing options...
Recommended Posts