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

custom isoBounds proportions #11

Open
mfpierre opened this issue Sep 29, 2014 · 8 comments
Open

custom isoBounds proportions #11

mfpierre opened this issue Sep 29, 2014 · 8 comments
Assignees

Comments

@mfpierre
Copy link
Contributor

Currently isoBounds are only determined for matching a cube inside a given sprite, is there a way to have a custom shape ?

Example for this wall sprite :

isobound

My main problem is to have the depth sorted properly, is there another way to achieve that other than cutting sprite into smaller cubic pieces ?

@lewster32
Copy link
Owner

If you enable physics on the IsoSprite then it will use the body instead of the calculated isoBounds - you can then adjust the body with body.setSize() - though I agree, you should also be able to specify the isoBounds, so this will be added.

@lewster32 lewster32 self-assigned this Sep 30, 2014
@mfpierre
Copy link
Contributor Author

Thanks, I have one more question regarding anchor and sorting.

As I understand, the sprite anchor is the point from where the sprite is rendered and moved (did not find any doc about the anchor). Why does it affect depth sorting ?

If I set my anchor to [1,1] the wall is always on top of the character (and [0,0] the character is always on top)

capture d ecran 2014-09-30 a 14 40 14

If I set my anchor to [0,0.5] I can get behind on the upper part but there is flickering on the bottom part, it's pretty much the same behavior for [0.5,0.5]
capture d ecran 2014-09-30 a 14 51 36
capture d ecran 2014-09-30 a 14 52 00

So my question is what is really the impact of the goal of the anchor and it's impact and what cause the flickering with the topological sort ?

@lewster32
Copy link
Owner

To be totally honest with you, there are aspects of the anchor functionality at the moment which I don't fully understand - the majority of the plug-in has been a case of adapting existing Phaser code such as the Sprite, Arcade and Arcade.Body objects to work with a third dimension, but some things have not translated well, such as anchor position, which in Phaser actually alters the body position. This is fine in a 2D world where you can map a rectangle to another rectangle, but in a 3D world the anchor has to translate to a cube and that's where things start to get a bit weird.

My approach has been to pretty much sidestep the problem and ensure the anchors are the same on all objects in a scene. Usually setting them all to 0.5, 1 means they're anchored from the bottom which is usually what you want in the isometric world, as in isometric space, up is up (positive), whereas in Phaser's orthographic space, up is down (negative) - but that's not really a solution, and I should delve deeper into what's happening with anchors, and how changing it will affect the depth sorting.

@solusipse
Copy link

I'd like to ask a question about anchors, guess it's fine place to do that. I would like to select object as in pointer interaction demo (http://rotates.org/phaser/iso/examples/interaction.htm), but I would like to trigger event only when cursor is withing cube's bottom. Is it possible? I got nice top trigger when anchor is set to [0.5,1], but when i set it to [0.5,0] it's events are being triggered when mouse is much below cube's bottom. There's a picture illustrating my problem:

anchor problem

@lewster32
Copy link
Owner

The key here I think is leaving the anchor alone and instead offsetting the assumed Z position of the mouse position:

game.iso.unproject(game.input.activePointer.position, cursorPos, 32);

Change the last parameter (32) to a value that's appropriate for where you want the Z-plane of the pointer to be.

As for anchors, I think they're still pretty much an unknown within the context of isometric projection unfortunately. It'd be really great for someone to take a look at that part of the plug-in and see if they can improve it somewhat... hint, hint!

@solusipse
Copy link

Thanks a lot! I did this:

Game.game.iso.unproject(Game.game.input.activePointer.position, cursorPos, tile.body.height*-1);

and it worked like a charm. I wanted to try with anchors first, I assumed it's the right way to do that. Thanks for the plugin btw, it's awesome.

@lewster32
Copy link
Owner

You're welcome :) BTW I'd suggest changing your projectionAngle for that artwork if you've not done so already - you can see the bounding cubes aren't matching the angle of your artwork correctly. Looks like it's about 34° so your angle wants to be something like 0.593412.

@solusipse
Copy link

That was just a placeholder, I decided to use default angle. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants