Skip to content
This repository has been archived by the owner on May 8, 2018. It is now read-only.

sprite.anchor broken #51

Open
FantomHD opened this issue Jan 24, 2017 · 2 comments
Open

sprite.anchor broken #51

FantomHD opened this issue Jan 24, 2017 · 2 comments

Comments

@FantomHD
Copy link

Hi,

I've noticed the anchor property, specifically changing it, is broken with the plugin, but only after setting the physics of the sprite to iso mode. The sprite's position gets radically changed. If i set the anchor to 0.001 the sprite begins to slowly move to the left (very slow lol) but if i set it to .5 its thousands of pixels away instantly, and does not continue moving.

to replicate:

create a sprite,
enable isoArcade phsyics (if you do not do this first there is no problem)
do sprite.anchor.setTo(.5); or sprite.anchor+=.5
check the position of the sprite, as its now very far away. For me I got a negative value every time.

@FantomHD
Copy link
Author

Update: I've found the source of the issue. sprite.anchor.setTo(x, y) is actually sprite.anchor.setTo(x, z) for some reason. When i do sprite.anchor.y = .7 it modifies the sprites z rather than y.

@FantomHD
Copy link
Author

FantomHD commented Jan 28, 2017

Update: It's been fixed, but ill keep the issue open, maybe you should update the plugin with the fix as this is a pretty big part part of phaser.

I changed lines 2467-2468 in the plugin source.

I changed:

this.position.x = this.sprite.isoX + ((this.widthX * -this.sprite.anchor.x) + this.widthX * 0.5) + this.offset.x;
this.position.y = this.sprite.isoY + ((this.widthY * this.sprite.anchor.x) - this.widthY * 0.5) + this.offset.y;
this.position.z = this.sprite.isoZ - (Math.abs(this.sprite.height)*(1-this.sprite.anchor.y)) + (Math.abs(this.sprite.width * 0.5)) + this.offset.z;

to

this.position.x = this.sprite.isoX + ((this.widthX * -this.sprite.anchor.x) + this.widthX * 0.5) + this.offset.x;
this.position.y = this.sprite.isoY + ((this.widthY * this.sprite.anchor.y) - this.widthY * 0.5) + this.offset.y;
this.position.z = this.sprite.isoZ - (Math.abs(this.sprite.height)) + (Math.abs(this.sprite.width * 0.5)) + this.offset.z;

looks like it was a simple mistake?

@Niko-O Niko-O mentioned this issue Mar 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant