Jump to content

game.Graphics set anchor point ?


SkyzohKey
 Share

Recommended Posts

Hello !

 

How am I supposed to set the anchor point for a game.Graphics object ?

 

Here's my code : 

this.sprite = new game.Graphics();this.sprite.beginFill(this.border);this.sprite.drawRect(0, 0, this.size.width, this.size.height);this.sprite.beginFill(this.background);this.sprite.drawRect(0 + this.borderSize, 0 + this.borderSize, this.size.width - this.borderSize * 2, this.size.height - this.borderSize * 2);this.sprite.position.set(this.position.x, this.position.y);// this.sprite.anchor.set(0.5, 0.5) is not working :/

Thanks a lot for your futures answer ! :)

 

EDIT : SOLVED MY PROBLEM BY DOING THIS :

this.sprite.drawRect((-this.size.width / 2), (-this.size.height / 2), this.size.width, this.size.height);this.sprite.position.set(this.position.x - (-this.size.width / 2), this.position.y - (-this.size.height / 2));

Thanks to enpu to make me in the right way ^^

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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