Jump to content

c.Graphics (rect) and anchors?


NooneKnows
 Share

Recommended Posts

Hello all guys. I have one question.

does anchors work with Graphics?  if no - how i can set  something like anchor? 

i tried  - anchor.setTo(0.5,0.5) ,anchor.set(0.5) , anchor.x\y etc. The  properties of object changes. but rect still rotating around the lower right corner. set(0\1) - same. no effect.

 

rotate.gif

 

Link to comment
Share on other sites

actually - not very right. just change ang. from center, like here:  http://phaser.io/examples/v2/sprites/sprite-rotation . and not from corner one.

but the problem - i cant set anchor for rect. is there that property, but it ignores it? ... with sprite ( image ) - no problems.

maybe i need to set centerX and centerY ? or wrong too?

Link to comment
Share on other sites

I don't know very well the graphics object inner workings but as a workaround you can generate a sprite from it using its generateTexture() method:

sprite = game.add.sprite(100, 100, graphics.generateTexture());

As an alternative if you are changing the graphics shapes or adding more graphics to it you can add the graphics object as a child of the sprite

sprite = addChild(graphics);

Then you can control the rotation using the sprite anchor and pivot properties.

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