4
\$\begingroup\$

I'm a noob when it comes to programming Java apps, so I'm trying to make a very simple platformer game. All is running very well on desktop project, but when I put the game on my Xperia a "strange" thing happens...I'm using Tiled to draw the map, and on code OrthogonalTiledMapRenderer and TiledMap, with a OrthographicCamera, I "zoom" with camera.setToOrtho a part of the map. The problem here is...

I have an elevated floor and other tiles, and on phone screen, this all appears squashed: the tiles and the elevated floor display in a lower position than the desktop version, which is an ugly problem. Resizing the window on PC, all runs and resizes good, mantaining the aspect ratio.

Sorry if I don't explain the problem very well, I'm lost on this theme! xD I thank tutorials, examples and all other things for noobs. I tried all viewports and still have not solved the problem, a good way I think is cut off the top part when resize, but I don't know how to do it!

Edit: I add the screenshots, this part of code is from a good book from packt, and I don't know if I can share here here, I prefer not do it, I'm only learning at the moment, and a comment that saying a track to try solve this is sufficient, here are: enter image description here

The figure is a sprite on code, the floor and the "door" are layers on tiled (floor and doors). I configured as 16x16 tiles, but configuring as 32x32 or more is the same.

The second image is the regular window, and the last is at the minimum size window, but the aspect is the same that on the more big window...If I stretched out the window, all is stretched, but the upper floor and the sprite maintains the same distance. I don't understand what is happening on the mobile version...

\$\endgroup\$
  • \$\begingroup\$ It's a bit difficult to help with so little information, can you add a screenshot of what it looks like and maybe share some code you think might be relevant? \$\endgroup\$ – bornander Mar 14 '16 at 7:01
  • \$\begingroup\$ I edited the first post \$\endgroup\$ – Jordi4321 Mar 14 '16 at 10:20
  • \$\begingroup\$ Do you call mapRenderer.setView(camera); or mapRenderer.setView(projectionMatrix, startX, startY, endx, endY); whenever you change your camera position? \$\endgroup\$ – spectacularbob Jul 18 '16 at 21:43
0
\$\begingroup\$

I usually spend this...but here I thought it would be impossible to find the answer for myself, it has not happened. The book uses a "different" technique to resize objects on game, not a ViewPort. Well, the solution (working at the moment) has been:

  1. A fixed size to the sprite (character.setsize(3,5)).
  2. Apply a ScreenViewport().

And that's it all....

I found this asking a question on libgdx IRC channel, an user said to try with different screen configurations on code, changing Gdx.graphics.getWidth() and getHeight() to a screen values of the phone, and I tried that on pc version, and, after a lot of tries, it worked!!!

Sorry for asking this without some code...

Thank you!!!

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.