espace

possible to stop a tween ?

Recommended Posts

 

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)

 

Share this post


Link to post
Share on other sites

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() {
}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.