Jump to content

How can I rotate a line?


Recommended Posts



I want to rotate a line from an anchor point but I'm having an issue trying to do this "simple" operation. 


this is my code:



this.angle = 0;this.graphics = game.add.graphics(50, 50);


if (game.input.activePointer.isDown) {      this.angle += 10;      var front = new Phaser.Point(1, 0);      front = Phaser.Point.rotate(front, 50, 50, this.angle, true);      this.graphics.kill();      this.graphics = game.add.graphics(50, 50); //could use moveTo      this.graphics.lineStyle(1, 0x0000ff, 1);      this.graphics.lineTo(front.x,front.y);    }

The result i'm getting is a line rotating but not in the expected way , it seems it's stuck inside a rectangle. It's like I need to set an anchor point ...


I'm sure I misunderstood the rotate method or the math behind (maybe both :(  )

Link to comment
Share on other sites


  • Recently Browsing   0 members

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