Open mfpierre opened 10 years ago
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.
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)
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]
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 ?
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.
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:
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!
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.
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.
That was just a placeholder, I decided to use default angle. Thanks!
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 :
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 ?