InsOp Posted September 14, 2015 Share Posted September 14, 2015 Hey, I have a 2d field with units occupiing several fields. I change position of this units once in a while - but the data for the positionscomes from a node server. that being said: i have some "airunits" and I wanted to implement a certain shaking - to create an illusion of them floating.So I added this codegame.phaser.add.tween(unit.sprite) .to({x:unit.sprite.position.x+1,y:unit.sprite.position.y-1}, 400, Phaser.Easing.Bounce.InOut, true, 0, -1, true);works like a charm except for some critical aspects:I cannot move my unit around, now since the tweening interferes with my manual sprite positioningI wouldve liked it more randomized, so my aircraft does float more casualI could have implemented this aspect by myself somehow, but I like the smooth easing.Is there a good approach for this issue? Is the issue sufficient described? Link to comment Share on other sites More sharing options...
mcolman Posted September 14, 2015 Share Posted September 14, 2015 Hi, few suggestions for you.1. Add your unit.sprite to a Phaser.Group. Then you can shake tween unit.sprite and move the unit around yourself by moving the group.2. Instead of setting your tween to repeat forever, just tween it once and use the onComplete signal to tween it again with random values.Also using separate tweens for the x and y values with different durations will create a more random feel. InsOp 1 Link to comment Share on other sites More sharing options...
InsOp Posted September 14, 2015 Author Share Posted September 14, 2015 perfect - thank you! Link to comment Share on other sites More sharing options...
Tom Atom Posted September 15, 2015 Share Posted September 15, 2015 Hi, you can make custom easing function with parameters that will move or shake your airunit forever. I wrote 3 part tutorial on making simple game and in part 2 there is "wiggle" function for dron (http://sbcgamesdev.blogspot.cz/2015/05/phaser-tutorial-dronshooter-simple-game_9.html) Here is also tutorial for creating custom easing functions that can take parameters other than "k": http://sbcgamesdev.blogspot.cz/2015/04/phaser-tutorial-custom-easing-functions.html Link to comment Share on other sites More sharing options...
Recommended Posts