-
-
Notifications
You must be signed in to change notification settings - Fork 647
Add support for viewport resize / zooming #138
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
Comments
The idea here is to be able to zoom into the game without the viewport resizing. In the following two examples you zoom with the mousewheel and drag the viewport with mousedown. Same functionality in an HTML5 game: Additionally, this is a lot more useful if you can zoom into the game without the gui and hud zooming. See the game above for an example. I think one way to do this would be to have buffer objects that you can create and then assign other objects to. So you could assign everything accept the gui and hud to be rendered in one buffer object and the gui and hud in another. You could zoom one buffer and then have them both rendered on top of each other on the canvas. |
How about some autoresizing of the viewport? i mean, without scaling the content, adjust the viewport to show more of the map... |
Does any of you has any idea or suggestion on how to manage this from an API point of view ? I mean how these features should be available from an end-user point of view ? |
hmm maybe the autoresizing of the viewport could be when the autozoom feature is false, and the mantainAspectRatio is false too? |
Autoresizing of the viewport was dealt with in ticket #4. I'm not sure if it should be me.game.zoom or me.video.zoom or something else, but for shorthand I will just write game.zoom for now. game.zoom zoom is a multiplier. It multiplies the already autoresized viewport contents. 1 is default, no zoom. zoom.min and zoom.max allow you to set min and max zooming, e.g., min zoom might be set to 1 and max zoom set to 2. Defaults would be null. HUD and GUI objects should have a zoom flag defaulting to true. If they are set to false, then they will not zoom. game.zoom = 1.5 myHUD_Object.zoom = false On the backend, the best way to deal with this would probably be to draw HUD and GUI objects with zoom set to false on their own buffer, zoom the main buffer and then draw the HUD and GUI buffer on top of the game buffer. Originally my idea was to allow the user to create custom buffers and assign whatever objects they want to each one and assign each buffer a z-index, but that is a lot more complicated, and I couldn't think of any use cases for it. It's a lot simpler if just GUI and HUD Objects can be individually flagged not to zoom and thus there are only two buffers at most and the user doesn't deal with them directly. |
Alternatively, you might just have one flag for all HUD objects and one flag for all GUI objects. game.zoom // defaults to 1 |
I just thought of a situation where I'd probably want to use something other than a GUI or HUD object in the unzoomed top buffer. So it might be nice if other types of objects had a zoom flag. For instance, the user is zoomed in, and then the game ends. On top of the game I write in big letters either, "Defeated" or "Victory!". If it says victory there may be a fireworks particle effect behind the word. Even though the rest of the game is zoomed in, I wouldn't want the Victory and particle effects to be zoomed. Obviously, using two buffers, anything that does not zoom will always be on top of stuff that does zoom. For the use cases I can think of this works well. I think they can all still use the same sort for z-index, the objects are just rendered to two different buffers. So if I run me.game.sort and assign z-index values to everything, those values would not change even though there are two buffers, but anything drawn to the non-zooming buffer would be on top of the stuff in the main zooming buffer. You could make it more complicated and give both buffers their own sort functions but I really don't think it's necessary. |
- Lots of weirdness here! - Small maps are centered by adjusting me.game.currentLevel.pos - The world container is translated to the map position; the world container's position is untouched (!) This causes the world container position to be incorrect as you can see in the debugPanel - me.Container.draw: - The renderer is transformed by the container transformation matrix (same as map position for world, all other containers will have a the identity matrix) - Then the renderer is translated by the container position (<0,0> for world, <x,y> for every other container... *sigh*)
i'd say that viewport resize capabilities is done ! |
Almost. ;) It only resizes one dimension of the viewport today. |
the flex settings yes, but the |
Got it! Yes, I think so, too. |
Zoom can be done pretty easily thanks to #704! See the following forum post for details: https://groups.google.com/forum/#!topic/melonjs/fAtFFe2wvCo How we want to expose this to end users is an open question! |
i think this ticket can now be closed together with #335 (see there for example) since we do now (and finally) provide a clean way to zoom and even apply any transformation to the level without impacting the viewport. |
@see ticket #4
The text was updated successfully, but these errors were encountered: