![]() ![]() tWrap(TextureWrap.Repeat, TextureWrap. Private static float scrollFactor = 0.2f I’m trying to calculate the scrolling speed of an background, I’m doing something like this on the background class: private Texture texture = new Texture(("backgound.png")) So it stretches the image but keeps the aspect ratio:Īnd if I run the game with any other resolution like for example 700×500 I get this: Now if I set the game resolution to be 480×800 right at the beginning, it basically works except that if I change the window size, the resolution keeps to be 480×800. ShapeBatch.rect(0, 0, viewport.getWorldWidth(), viewport.getWorldHeight()) Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT) Img = new void resize(int width, int height) Viewport = new FitViewport(VIRTUAL_WIDTH, VIRTUAL_HEIGHT) Public static final int VIRTUAL_HEIGHT = 800 And that’s the code: public static final int VIRTUAL_WIDTH = 480 If the screen size is different it should scale the resolution and use letterboxing. Basically I want to support 480×800 for my game. I’m trying to understand how LibGDX handles screen size / resolution, etc.Ĭoming from XNA this seems very confusing to me. If there are any substitutes of this library that you know of please let me know! On a side note: The only reason I am using box2D is so I can achieve a nice lighting effect with shadows and everything with box2DLights. I am looking for any other ideas that might help. This however increases the number of bodies in the box2d world compared to the previous solution where there is just 1 body for each group of solid tiles. ![]() Each of these sections would handle their own irregular polygon so that when a tile was destroyed only that section would need to be updated and recalcuated. To get around this, I then thought of dividing the chunk up into 4×4 sections. I would then have to recalculate all of the tile connections within that chunk and recreate another irregular polygon. This solution appears to be the best, however what would happen when I want to destroy a solid tile. I then came across a potential solution which would join all solid adjacent tiles within a chunk, so that instead of having a box for each individual solid tile, there would be a irregular polygon for each set of connected solid tiles. At chunk size 8 with boxes around only solid tiles performance was 60 fps on mobile devices, however this was only sustained when the chunks that were loaded did not contain many solid tiles so this isn’t really a solution. One partial solution I found to this is reducing the chunk size. Performance was still terrible because at one time there was 500-1000 individual boxes. I then tried creating a box shape for each of these tiles that are solid. On desktop, you create a JFrame or similar and add inside a Canvas, on Applet you just create the Canvas and add it to the Applet. I have tried creating a Static box shape for each of these tiles but performance was understandably terrible. Java lwjgl vs libgdx how to (note: using fullscreen is a different case but has no meaning for this post) How to resize an Applet Unless you want some custom behavior, I believe that is the common usage. This means that there are 2304 tiles active at all times. The maximum/minimum chunks loaded at one time is 9 (a 3×3 set of chunks with the player in the middle). Each world consists of a set of chunks, and each chunk is 16 tiles wide/long. I am trying to implement Box2D into my top down tile game in LibGDX. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |