JSFiddle - React, Tailwind, and code Playground
by espace3d
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.6.1/phaser.min.js"></script>
JavaScript
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() {
}