Jump to content

Rotation bug?


NePo
 Share

Recommended Posts

I have a square, I rotate it onClick 90 degrees.

Code:

pavement[id]['angle']+=90;
if(pavement[id]['angle']==360)
    pavement[id]['angle']=0;
game.add.tween(pavement[id]['sprite']).to( { angle: pavement[id]['angle'] }, 500, Phaser.Easing.Linear.None, true);

On 270 it spins like crazy, but if I rotate in different angle everything is okay.

Code:

pavement[id]['angle']-=90;
if(pavement[id]['angle']==-360)
    pavement[id]['angle']=0;
game.add.tween(pavement[id]['sprite']).to( { angle: pavement[id]['angle'] }, 500, Phaser.Easing.Linear.None, true);

Any suggestions/comments?

 

Link to comment
Share on other sites

I am sorry, originally when I posted the code I forgot to add plus as in your example. I was editing code many times so I posted both code samples wrong (Now I fixed them). 

Yes, I do add or detract 90 on each click but both code samples react differently. 

Its seems that the angle is 0 and 180, not -180. 

Thank you for your answer. 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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