-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
me.ImageLayer.achorPoint should map to the viewport boundary #632
Comments
This code allowed me to set the x/y coordinates of the ImageLayer properly
Might be useful |
@xorinzor Why are you subtracting the absolute origin from the viewport position? Shouldn't it be the other way? Subtract the viewport position from the origin... |
@parasyte Doing it the other way around creates negative values which result, when drawing, in things like: |
Oh right, because it's changing the source coordinates. 😒 The |
- This shows a potential optimization path; melonJS should only use known regions, so we can remove this safety net code! - Requires Texture [atlas] support for TMX tilesets and bitmap fonts, at the very least
…ed in Tiled - `me.ImageLayer` constructor was updated to add two `x` and `y` parameters - the original `pos` property has been renamed to `offset`, which makes more sense since this specifies the start drawing offset in the image. - `pos` is now use as its should be, to specify the default drawing position of the image in the viewport - some cleaning in the constructor as well, remove some useless local var, as speed is not a real issue here.
note that with this last change, the anchor point is now also relative to the image default position, I'm not sure how this however answer to the original issue :P |
… the viewport boundary - TODO: Add repeat modes [#603]
- It looks like Tiled doesn't output imagelayer width/height, anyway.
- This is necessary when a me.ImageLayer is a child of a floating entity; normalize rendering for screen coordinates so there are no special cases.
- This removes a hack that would GC the ratio vector on new image layers.
- This was broken by the ImageLayer refactor. - Attempted fix was: b20d6ee
See also: #604 #332
The
anchorPoint
setting is unintuitive, as currently implemented. It maps the ImageLayer to the visible part of the viewport. And secondly, the ImageLayer position alters the source coordinates instead of the destination coordinates. Combined, these issues make it very difficult to accurately position an ImageLayer with absolute coordinates, or coordinates relative to the map.Here are some (really long) threads that also go over this topic, including a lot of workarounds for it:
For the most part, the workarounds allow things to work as expected. But this is clearly a difficult bug to deal with.
To provide a better technical description, the
anchorPoint
should map an ImageLayer to the viewport boundary, taking into account the ImageLayer size and the viewport boundary size. This mapping establishes the ImageLayer's origin. Then, as the viewport moves, the ImageLayer moves at a ratio proportional to the viewport position in relation to the viewport boundary. It is not easy to digest in writing, but in practice this will solve almost all of the issues around positioning an ImageLayer with an active ratio.The text was updated successfully, but these errors were encountered: