Phaser: Arc/Circle Position wrong

Created on 26 Jun 2019  路  6Comments  路  Source: photonstorm/phaser

Version

  • Phaser Version: v3.18.1-FB
  • Operating system: Windows 10
  • Browser: Tested in Chrome, FF, Chrome (Android)

Description


When drawing a circle (or arc) with .add.circle(), it is placed wrong. It is placed to far left and top. After some tests I can say it is placed 0.5 times of its radius in negative x and y direction, from the expected position.

Example Test Code


Placing a circle in the left top corner, to fit exactly, without setting the origin.
Expectation:
this.add.circle(200, 200, 200, 0xff0000);
What is needed in this Version:
this.add.circle(300, 300, 200, 0xff0000);

Additional Information


See your own example:
http://labs.phaser.io/view.html?src=src/game%20objects/shapes/blend%20modes.js&v=3.18.1

Btw. it would be nice, if the version could also be set in the editor for the examples.

Most helpful comment

Actually, see the test case in this pen. The circle's origin is not changed and its coordinates are at the center of the canvas, but it is not rendered where you'd expect. Additionally, it only happens with the WebGL renderer. If you set the type in the config to Phaser.CANVAS, the circle will appear where it's supposed to.

I suspect that the indirect cause of this is commit 382afd6, coupled with the offset applied in the updateData method of the Arc, however, I haven't looked much further into this.

All 6 comments

I believe this is intended behaviour in order to be consistent with other objects (which all default their origins to 0,0). If you need to position your circle from its centre then change the origin.

The editor version can be set, just change the query parameter.

Actually, see the test case in this pen. The circle's origin is not changed and its coordinates are at the center of the canvas, but it is not rendered where you'd expect. Additionally, it only happens with the WebGL renderer. If you set the type in the config to Phaser.CANVAS, the circle will appear where it's supposed to.

I suspect that the indirect cause of this is commit 382afd6, coupled with the offset applied in the updateData method of the Arc, however, I haven't looked much further into this.

I can confirm that change of position in circles.
My app before the changes:

image

after 3.18

image

Both of them are setOrigin(0.5)

Can confirm, you can see the differences if you alternate between the links provided above:
http://labs.phaser.io/view.html?src=src/game%20objects/shapes/blend%20modes.js&v=3.17.0
http://labs.phaser.io/view.html?src=src/game%20objects/shapes/blend%20modes.js&v=3.18.1

Setting setOrigin(0.25) fix this. But i think it's a temporary fix

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lilijreey picture lilijreey  路  4Comments

Secretmapper picture Secretmapper  路  3Comments

cncolder picture cncolder  路  4Comments

JarLowrey picture JarLowrey  路  4Comments

samme picture samme  路  3Comments