Uibon Posted March 17, 2014 Share Posted March 17, 2014 Personally I am very new to game development and have recently picked up phaser. I have seen a lot of phaser games use tweening. I do not understand what it means. The examples on the website do not clear it up either. Can anyone explain to me what tweening is and how it related to phaser? Link to comment Share on other sites More sharing options...
XekeDeath Posted March 17, 2014 Share Posted March 17, 2014 Tween is an animation term. You define a pair of keyframes: beginning and end, and the computer will compute the in-beTWEEN frames. Wiki-link! In Phaser, you create Tween objects that will handle changing values from what they currently are, to what you want them to be. Examples are a sprites position, rotation, scale, alpha. Usually the transition of values is linear, but Phaser has some other built in options for different effects. Link to comment Share on other sites More sharing options...
Uibon Posted March 17, 2014 Author Share Posted March 17, 2014 i do this but it does not work..? any Ideas? if (side === 0) { enemy.reset(wh/2,0); game.add.tween(enemy).to( {y: wh}, 3000, Phaser.Easing.Linear.None).start(); } else if (side === 1) { enemy.reset(wh,wh/2); game.add.tween(enemy).to( {x: 0}, 3000, Phaser.Easing.Linear.None).start(); } else if (side === 2) { enemy.reset(wh/2,wh); game.add.tween(enemy).to({y: 0 }, 3000, Phaser.Easing.Linear.None).start(); } else if (side === 3) { enemy.reset(0,wh/2); game.add.tween(enemy).to( {x: wh}, 3000, Phaser.Easing.Linear.None).start(); }side is a randomly generated number to indicate starting side while wh stores the game dimensions(300, 300) Link to comment Share on other sites More sharing options...
XekeDeath Posted March 18, 2014 Share Posted March 18, 2014 wh is a point? You want to do wh.x or wh.y then. Also note that you have access to game.width and game.height that are the dimensions of the game. Link to comment Share on other sites More sharing options...
Uibon Posted March 18, 2014 Author Share Posted March 18, 2014 No, wh is a number, yet it still does not work. I use this in my create function and it works testEnemy = game.add.sprite(0,0,'e1'); game.add.tween(testEnemy).to({x: 300,y: 300}, 2000).start();But does not work when I use it like this:if(rand_int(2) === 0) { enemy = enemies1.getFirstExists(false);} else { enemy = enemies2.getFirstExists(false);}enemy.reset(wh/2,0);enemy.x = wh/2;game.add.tween(enemy).to({x: 300,y: 300}, 2000, null, true); Link to comment Share on other sites More sharing options...
Recommended Posts