Jump to content

Positioning question (drawing a simple circle)


Threedy
 Share

Recommended Posts

This may be a ridiculous simple question, but I can't figure this one out...

I tried drawing a circle using the following function:

drawCircle(x, y, radius)

Where x and y are according to the documentation of Pixi:

Quote

The X/Y coordinate of the center of the circle

If I want to change the position later, I can use the: circle.position.x or circle.position.y method. If I set both at (2,2) (position.x = 2 and position.y = 2), I see that the position is different than the one I used to create the circle with: drawCircle(2,2,1).

I then don't understand the API's ''the x,y coordinate of the center of the circle''.. Wouldn't that be the initial position of that circle anyway? 

Link to comment
Share on other sites

The thing is, what you pass in drawCircle is not a position, its coordinates of the circle relative to the graphics you are creating. So you have to use "graphics.drawCircle(0, 0, 1); graphics.position.set(1,1);"

To understand why API works that way, imagine that graphics has two circles in it. Which of two circles position will appear in "graphics.position"?

Link to comment
Share on other sites

22 hours ago, ivan.popelyshev said:

The thing is, what you pass in drawCircle is not a position, its coordinates of the circle relative to the graphics you are creating. So you have to use "graphics.drawCircle(0, 0, 1); graphics.position.set(1,1);"

To understand why API works that way, imagine that graphics has two circles in it. Which of two circles position will appear in "graphics.position"?

Thank you Ivan!

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...