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

Tile Rotation (Flipping axis) #55

Open
dud3 opened this issue Jun 12, 2017 · 6 comments
Open

Tile Rotation (Flipping axis) #55

dud3 opened this issue Jun 12, 2017 · 6 comments

Comments

@dud3
Copy link

dud3 commented Jun 12, 2017

Is the following correct: https://stackoverflow.com/questions/39799689/phaser-how-to-rotate-an-isometric-body

If not, can we rotate the tile like the link above describes?

@dud3
Copy link
Author

dud3 commented Jun 13, 2017

Ping.

@dud3
Copy link
Author

dud3 commented Jun 13, 2017

@lewster32 what if we rotate the tile so that'll be parallel to the isometric axes?

@lewster32
Copy link
Owner

Sorry for the delay - yes, you cannot rotate bodies as their edges must be aligned to the isometric axes. Rotating doesn't really make a lot of sense in an isometric scene as due to the sprites being 3D representations, any rotations would typically have to be entirely redrawn (i.e. entirely different frames, rather than just transformations to an existing frame). I don't think I'm entirely understanding what you're trying to achieve, so if you have an example then I can try to be more specific, and maybe suggest workarounds.

@dud3
Copy link
Author

dud3 commented Jul 3, 2017

@lewster32 Sorry for my late reply as well, the following is what I'm trying to achieve:

countrylife-001
countrylife-002

BTW: sorry, it's not a usual rotation, we're not using any trig functions, simply flipping x and y axis.

Guessing the following does the flipping transformation y=x, after applying it the bouds don't get recalculated.

var cow = game.add.isoSprite(100, 100, 0, 'animal-cow-brown', 0);
cow.width *= -1;

How do we calculate the bound of an object?
What about the height of an isometric object?

I think there must be something wrong with the bounds calculation, they don't seem accurate.

@dud3 dud3 changed the title Tile Rotation Tile Rotation (Flipping axis) Jul 3, 2017
@lewster32
Copy link
Owner

lewster32 commented Jul 4, 2017

Does flipping the scale not work? That is how I'd normally do this in Phaser.
cow.scale.x *= -1

@lewster32
Copy link
Owner

lewster32 commented Jul 4, 2017

Appears not - the issue seems to be that bounds are initially derived from the sprite size and assumed to be cubic. When changing the scale or width, any non-cubic bounds are not then automatically updated. I guess the workaround is to manually update the bounds yourself when changing the orientation of the sprite, as there is naturally a looser orientation between the sprite and its body with an isometric system; it has to assume some basic things about the sprite, as it cannot interpret any orientation or shape other than the cubic bounds it should occupy for its size.

In order to set your own bounds, you would use cow.body.setSize as documented here.

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

2 participants