Jump to content



Recommended Posts



I am trying to understand the Sprite.anchor property. Is it essentially where a touch/mouse point will be anchored relative to the sprite's bounds? Any other implications of changing anchor points?


In one case, I was playing with the pixi dragging example, and found that not setting the anchor would cause a mouseup to not register so easily, presumably because the mouse pointer was at the edge of the top-left corner by default. So I was in practically perpetual drag mode :).


Thanks for your help, and for an awesome, reasonably-sized, and free library.


PS. Am pretty new to pixi.js and 2D game dev in general, so pardon the dumb questions, if I did not phrase things right, or used the wrong terms, please correct me.

Link to comment
Share on other sites

Hey there! You are spot on! not setting the anchor point means that the top left corner is the 0,0 of the sprite. Here is a little more info on anchor points:


Its important to note that the anchor point is not a pixel value,  it is a % of the texture’s dimensions with a range from 0.0 to 1.0 (0% to 100%). If the anchor point is 0×0 (pixi.js’ default), then the texture’s upper left corner aligns with the sprites position. If the anchor point is 0.5×0.5 then the texture is centered on the sprites position. If the anchor point is 1×1 then the texture’s lower right corner aligns with the sprites position.


Hope that helps!

Link to comment
Share on other sites

Thanks for your reply. Now I am having trouble understanding the relationship between the texture and the sprite. My understanding is the sprite's bounds are defined by the texture's size -- so does this change/move with changing anchor points? But in terms of rendering though, I don't see the sprite looking any different? How does anchoring affect something like the hitArea?

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.

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.


  • Recently Browsing   0 members

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