Search the Community
Showing results for tags 'yoyo'.
-
I have been working with phaser for less than a week, working off of some sample code. I am able to load the sprite. Have the sprite walk/tween 50 pixels back and forth with yoyo. But I can't figure out how to get it to change animation from 'left' to 'right'. You may recognize parts of the code in the sample below, I even left some other attempts commented out so that you can see I did search this site and Google my problem, but I can't find a solution. Basically, I want to have the sprite constantly patrol, and the yoyo works fine. But after each tween, I need to switch the animation so the person faces left or right. Any ideas will be helpful! var spriteX = this.game.add.sprite(600, 1000, 'walking'); var tween = this.add.tween(spriteX); spriteX.frame = 3; spriteX.animations.add('left', [9, 10, 11], 10, true); spriteX.animations.add('right', [3, 4, 5], 10, true); spriteX.animations.play('left'); tween.to({ x: 650 }, 1000, Phaser.Easing.Linear.None, true, 1000, -1, true); tween.onComplete.add(doSomething, this); function doSomething () { spriteX.animations.stop('left'); spriteX.animations.play('right'); } tween.to({ x: 600 }, 1000, Phaser.Easing.Linear.None, true, 1000, -1, true); //spriteX.animations.play('left'); //spriteX.animations.stop('left'); tween.repeatDelay(1000); tween.yoyoDelay(1000); //spriteX.animations.stop('right');
-
Hi everyone. I'm stucked at tweens. So, i have yoyo tween. In first, i want to check that yoyo has reached it "middle" (before/on loop back), is there any way to check that? The second question: at the docs we can see But, in my case the both methods will be called. Am i doing something wrong? Here is my code : this.p2AttackAnim = this.game.add.tween(this.p2).to({ x: 300 }, 500, Phaser.Easing.Bounce.Out, false, 0,0, true); this.p2AttackAnim.onStart.addOnce(function(){ this.p2.frame = 2; }, this); this.p2AttackAnim.onComplete.addOnce(function(){ this.p2.frame = 0; this.p1.frame = 1; }, this); this.p2AttackAnim.onLoop.addOnce(function(){ this.p1.frame = 1; }, this);
-
Hi there, I have a problem here... I´m not being able to change the Y destination of a sprite I´m tweening and with yoyo()... I have an item that I tween to an arbitrary position, then I "yoyo" the item to the original position and then I want to tween it again to another arbitrary position buuuuuuuut I´m not being able to do it. Does anyone how to do this? this.positionY = this.game.rnd.between(-100,-50);var myTween = this.game.add.tween(this.mySprite).to({y:this.positionY}, 2000, Phaser.Easing.Cubic.InOut, true, 0, -1);myTween.yoyo(true, 200);myTween.onLoop.add(function(){ this.positionY = this.game.rnd.between(-100,0); myTween.properties.y = this.positionY;},this)Thanks in advance.
-
Hi there. I stumbled upon a possible bug in Phaser.Tween.yoyo. It might be a mistake in my approach as well. Here's the simplest possible test case: http://phaser.io/sandbox/edit/iTbKujZu I'm tweening a sprite along a path of points and if I don't use yoyo, it's fine. If I only use a single value for each tweened property (e.g. {x : 300, y : 300}), it's also fine. But if I pass an array of values and use yoyo, the sprite jumps to an unexpected location after the loop. Note: the sandbox is still using Phaser 2.3.0, but that's fine since I'm still using the same version in the game I'm making. Edit: Added an alert at the end of the tween to show the resulting wrong values of x and y.
-
Hi there, I have a problem with the yoyo function. I want to create a tween with more than one movment and yoyo this. I tried following ways: var sp = this.add.sprite(100,100,"btn");var tween = this.add.tween(sp);tween .to({x:200}, 500) .to({y:200}, 500);tween.yoyo(true).start();and var sp = this.add.sprite(100,100,"btn");var tween = this.add.tween(sp).to({x:200});var tween2 = this.add.tween(sp).to({y:200});tween.chain(tween2);tween.yoyo(true).start();But it doesn't "yoyo" the complete animation. How can I do this? Thanks!