NooneKnows Posted June 8, 2016 Share Posted June 8, 2016 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. Link to comment Share on other sites More sharing options...
glantucan Posted June 8, 2016 Share Posted June 8, 2016 I think you are looking for the pivot property not the anchor one http://phaser.io/examples/v2/sprites/pivot Link to comment Share on other sites More sharing options...
NooneKnows Posted June 8, 2016 Author Share Posted June 8, 2016 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 More sharing options...
glantucan Posted June 8, 2016 Share Posted June 8, 2016 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 More sharing options...
Recommended Posts