Search the Community
Showing results for tags 'Phaser tween'.
-
function moveBal(n) { if (n < baloni.children.length) { var balonX = gWidth * Math.round(); var balonY = gHeight * Math.round(); var timeFor = moveTime * Math.round(); game.add.tween(baloni.children[n]).to({ x: balonX, y: balonY }, timeFor, Phaser.Easing.Quadratic.InOut, true,5,-1,true); } } http://kplusplus-001-site1.atempurl.com/babalon.html I cant that ballons move non stop. Please help me.
-
Hello, I am making a simple Matching game, that uses phaser tween animation to tween the animation for flipping game tiles. when the tile is flipped I need to set a state to OPEN or CLOSED however its currently using 4 methods to do the flip. I want to make it faster, so the user can not click on a new tile before the last one is completed here are 2 examples: I am writing the app in typescript. // Main.ts NEW click methods public startNewFlip():void { var tileNewTween:Phaser.Tween; tileNewTween = this.game.add.tween(this.face.scale).to({x: 0}, 300, Phaser.Easing.Quartic.In); tileNewTween.onComplete.add(this.onCompleteNewTileFlip1, this); tileNewTween.start(); } private onCompleteNewTileFlip1():void { if (this.currentState == TileState.OPEN) { this.face.frameName = "closedCard"; } else { this.face.frameName = this._id; } this.continueNewTileFlip(); } public continueNewTileFlip():void { var tileNewTween2 = this.game.add.tween(this.face.scale).to({x:1},300,Phaser.Easing.Quartic.Out); tileNewTween2.onComplete.add(this.onCompleteNewTileFlip2,this); tileNewTween2.start(); } private onCompleteNewTileFlip2():void { if(this.currentState == TileState.OPEN){ this.currentState = TileState.CLOSED; } else { this.currentState = TileState.OPEN; } }and here is what I tried to do to simplyfiy it public flip():void { if (this.currentState == TileState.OPEN) { var tileNewTween = this.game.add.tween(this.face.scale).to({x: 0}, 3300, Phaser.Easing.Quartic.In); tileNewTween.start(); tileNewTween.onComplete.add(function(){this.face.frameName = "closedCard"} , this); } else { var tileNewTween = this.game.add.tween(this.face.scale).to({x: 0}, 3300, Phaser.Easing.Quartic.In); tileNewTween.start(); tileNewTween.onComplete.add(function(){this.face.frameName = this._id;} , this); } console.log(this.currentState); this.contFlip(); } public contFlip():void { if(this.currentState == TileState.OPEN){ var tileNewTween2 = this.game.add.tween(this.face.scale).to({x:1},3300,Phaser.Easing.Quartic.Out); tileNewTween2.start(); tileNewTween2.onComplete.add(function(){this.currentState = TileState.CLOSED;},this); } else { var tileNewTween2 = this.game.add.tween(this.face.scale).to({x:1},3300,Phaser.Easing.Quartic.Out); tileNewTween2.start(); tileNewTween2.onComplete.add(function(){this.currentState = TileState.OPEN;},this); } console.log(this.currentState); }the anonymous function does not work correctly as it stops the animation from working, and swithes the tile after the 300 ms elapsed but without showing anything moving. This methods runs on a onFaceClicked() methhod, that lisens for mouse clicks on the tiles. if its tilestate is CLOSED, then runs this. But if click fast, the CLOSED state is not yet confirmed, so the app lets me click it.
- 2 replies
-
- phaser tween
- phaser
-
(and 1 more)
Tagged with:
-
Hey, im observing that youre having a slight acceleration with linear-easing tweening at the beginning and end of the movement: http://phaser.io/examples/v2/tweens/interpolation is there a way to get rid of it?
-
Is there a function in phaser tween that makes the image wave like a flag?