Jump to content

Rotation tween around arbitary point


Reicher
 Share

Recommended Posts

Hi!

 

I'm new to Phaser and are trying to make a simple game in which you can rotate the game board (90 degree steps). on the board there's a a few blocks that should be rotated along with the board. To rotate the board and the blocks around their center anchor points work well with tweens but I haven't managed to get the blocks to rotate nicely along with the board as described in the picture.

 

gOCke7G.jpg

 

So far my best solution is to tween the block positions but that doesn't look very good.

var goal = new Phaser.Point(this._block.x, this._block.y);goal.rotate(this._center.x, this._center.y, -90, true);this.add.tween(this._block).to({x: goal.x, y: goal.y}, 750, Phaser.Easing.Linear.None, true, 100);

 

I guess i could set the anchor point of each block to the center and then rotate, but how do I translate the board center position to the anchor point format? I could calculate a few points in an arc and interpolate between them. I also heard about tweening in bezier curves. 

 

Al this sounds like a bit of overkill, there must be an easier way? My first 10 Google pages are all purple  :unsure:

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...