Jump to content

Rotation sprite or group


NePo
 Share

Recommended Posts

I have a board. For simplicity lets say I have one, but I can have a lot.

Player click on the board, board rotates. Rotation is always 90 degrees. 

I attached image. First is starting position. Second is after two click. How I could achieve this?

I want to turn all board including all figures, but at the same time I want figures to point correctly. I want to make pretty animation.

At first I though to add everything to the group. But group does not have anchor, so turning around gets really awkward.

Any suggestions are welcome.

board.png

Link to comment
Share on other sites

Thank you for your answer.

1. Maybe I don't understand something, but rotate works only with points, not with sprites http://phaser.io/examples/v2/geometry/rotate-point#gv

2. I made figures children of my board.

Code from my game:

for(j=yy;j<yy+3;j++){
            for(i=xx;i<xx+3;i++){
                if(plaza[j][i]>0){
                    figures[plaza[j][i]]['sprite'].visible=false;
                    figures[plaza[j][i]]['child']=pavement[id]['sprite'].addChild(game.add.sprite(sizeS/2*(i-xx-1)-placeFig/2*(i-xx)+placeFig/2, sizeS/2*(j-yy-1)-placeFig/2*(j-yy)+placeFig/2, 'keeper'));
                    figures[plaza[j][i]]['child'].anchor.setTo(0.5, 0.5);
                    game.add.tween(figures[plaza[j][i]]['child']).to( { angle: -90 }, 500, Phaser.Easing.Linear.None, true);
                }
            }
        }
        
        tween = game.add.tween(pavement[id]['sprite']).to( { angle: 90 }, 500, Phaser.Easing.Linear.None, true);

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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