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

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

 Share

  • Recently Browsing   0 members

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