qbss Posted January 26, 2017 Share Posted January 26, 2017 Is there any way to rotate sprite (concretely coin) along z-axis? It is 3d efect but maybe achievable in canvas and phaser by setting scale or other properties. Ultimate efect I want to achieve can be done by such spritesheet: Link to comment Share on other sites More sharing options...
Tom Atom Posted January 26, 2017 Share Posted January 26, 2017 HI, what you want is in fact rotation alond Y axis (vertical one). You can fake it with changing scale X from 1 to -1 and then back. qbss and scheffgames 2 Link to comment Share on other sites More sharing options...
qbss Posted January 26, 2017 Author Share Posted January 26, 2017 Ok, one another problem is because my coin is asymmetric . So when I scale from 1 to -1, then I want to constantly rotate in the same direction (again from 1 to -1). So as far as I can see one solution is create 2 frame spritesheet (reverse parties) and when tween is complete set second frame , set scale again to 1 and then play tween again. Link to comment Share on other sites More sharing options...
Tom Atom Posted January 26, 2017 Share Posted January 26, 2017 Tween with yoyo should do all the job for you! Let's say, you have coin atlas and two sprites in it: "front" and "back". Then you can listen to onComplete and change frame in it: var sprite = game.add.sprite(0, 0, 'coin', 'front'); sprite.position.set(100,100); sprite.anchor.set(0.5, 0); var tween = game.add.tween(sprite.scale).to( { x: -1 }, 1000, "Linear", true, 0, -1, true); tween.onLoop.add(function() { sprite.frameName = (sprite.frameName === 'front') ? 'back' : 'front'; }, this); Diztraido 1 Link to comment Share on other sites More sharing options...
Recommended Posts