-
-
Notifications
You must be signed in to change notification settings - Fork 645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding shapes to a Body dynamically does not project shapes in isometric maps. #601
Comments
Hi ! I'm a bit surprise as based on the following code are you using the last master branch version (it's not called 2.0.0 but we just basically renamed it to 2.0.0 to emphasize on all the underlying changes) ? |
Oh sorry, allow me to clarify. calling init works, the entity displays on the map, etc but the moment it collides with something, unless getTMXShapes is there, I get an error. |
There should never be any uncaught exceptions. @ldd Can you please give us the line number where the exception is raised? And also point out which build you are using. (Build number in the melonJS-builds bucket on S3, or a git commit ID) This should be easy to fix, but an entity without a body shape is not supposed to collide with anything. Just keep that in mind. |
Um.... there is no error actually. Thus, the minor caveat is this: Looking at the code, rotation happens in TMXShapes in the last step, when you do
and body.getShape returns this.shapes[index] In other words, I guess there is no bug. The programmer needs to make sure that shapes are properly setup => feel free to close this bug report ps: I was using the tagged version 1.2.0-beta.1 |
hi ldd, great then, thank you anyway for reporting here your findind about the beta, bug or not this is always positive feedback to improve the engine :) |
Just one comment, here. I think it is a bug, because it's not trivial to add shapes to an entity at runtime with an isometric map. We can make it better. Eg. it might be something like the Anyway, this isn't a showstopper, so I think we can save it for 2.1. |
indeed, when not using Tiled there is no proper way to indicate the orientation ! maybe not a bug though, but a missing feature probably :) |
We should probably create a new issue dictating what needs to be done. I know we've looked at a bit of the shapes & tmx object data lately. What should be done in order to satisfy isometric shapes? |
I thought it was pretty clear by the description. But to describe further, when a shape is added to an isometric map (say a rectangle) it needs to be projected by rotation and scaling: melonJS/src/level/TMXObjectGroup.js Lines 387 to 392 in 0c173cb
An ideal solution would be to do the projection only when drawing. (Leave the shape and positioning internally to simplify entity movement.) The initial work (linked above) was done as a stopgap to ensure isometric map support wasn't completely missing. This ideal solution should be tracked in a different ticket. But completing the stopgap would happen here. |
Makes sense. That way you're not dealing with "isometric units" directly. Though do physic shapes get saved as projected? Could be weird to have onething projected, and another note.
alrighty |
In the ideal world, logical coordinates are always distinct from render coordinates; The axes do not necessarily point in any specific direction (relative to the screen) in a logical coordinate system. The shapes defined in the TMX are expressed in logical coordinates, which are roughly orthogonal. It's easiest to use these shapes directly for collision detection and entity movement. In other words, logical coordinates would be "native" to melonJS in that mode of operation. That's the eventual goal, anyway, since it breaks the coupling between world physics and renderer; theoretically, a game can be rendered in 2D or 3D just by changing the drawing code, while everything else remains untouched. |
Provided you put in 3d geometry ;) |
I mean that a simple renderer can just extrude shapes (pixels into voxels): There are other examples to be sure, but that's what I mean by rendering a game in 2D or 3D by only changing the renderer. With an isometric game, you really need 3D coordinate space, anyway. The isometric renderer can be easily swapped out with orthographic or perspective renderers... |
This applies for melonJS 1.2.0-beta
for reference, please look at
https://groups.google.com/forum/#!topic/melonjs/Tz8tUDHgDGw
I wanted to extend Entity objects without using Tilled.
This works perfectly, as done in the above forum post, but for 1.2 I needed to do
settings = {
//bunch of settings
orientation: "isometric",
getTMXShapes: new me.TMXObject('empty').getTMXShapes;
}
this._super(....,'init', [x,y,settings]);
With this small workaround, everything works perfectly and flawlessly.
put in other words:
either orientation or/and getTMXShapes are required in the settings when creating an Entity.
The text was updated successfully, but these errors were encountered: