Libgdx texturepacker giving atlas9/13/2023 ![]() The following is an image of the blurriness I am talking about: ![]() But, when rendering a TextureRegion, like: batch.draw(TextureRegion, x, y, width, height) if the width and height are greater than that of the original texture, it will scale each pixel, rather than blur the whole thing to try and make it look better. I must emphasize further that when rendering a scaled sprite, the scaling is not done by pixel, meaning that it is blurry. However, this does not solve the issue of scaling the sprite. ![]() Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT) ītProjectionMatrix(bined) Īfter further investigation, I have discovered that I can use t(Sprite sprite) to make Sprite x a copy of Sprite y, and therefore render each sprite multiple times. batch = new SpriteBatch() Ĭamera = new OrthographicCamera(GdxGame.WIDTH, GdxGame.HEIGHT) Ĭ(GdxGame.WIDTH/2, GdxGame.HEIGHT/2, 0) ĬtToOrtho(false, GdxGame.WIDTH, GdxGame.HEIGHT) Thus, everything is rendered as if the screen were 1920x1080. Though the Desktop window is scaled down from that size. Rendering Sprite: GdxGame.WIDTH/HEIGHT are 1920x1080. Public static Sprite sprite = atlas.createSprite("buttonUp") Loading from TextureAtlas: public static TextureAtlas atlas = new TextureAtlas(("data/texture/pack/output/pack.pack")) The code I am currently using to render/load the sprites is as follows: Even if I use batch.render(Sprite, x, y), I am unable to scale the sprite properly, because as I mentioned before, I would like to scale the sprite while maintaining a pixelated effect, and even so, using the Sprite.scale() method, this would scale the Sprite object as a whole, making it impossible to use the Sprite's texture multiple times for numerous game objects.Īny suggestions would be greatly appreciated. I am used to loading a Texture, then rendering this texture using batch.render(), at a given position, but I don't see how this is possible if I am using a sprite. Each sprite holds a texture that will represent a game object, however it is my understanding that you render a sprite using sprite.render(SpriteBatch batch), so therefore I could only use a sprite, loaded from the TextureAtlas for one game object, because I would also have to set the scale, and position of the sprite, as it represents the game object. Is this the proper way of rendering a sprite, after they are loaded using atlas.createSprite(String name)? I am new to using sprites, and loading textures from a texture-atlas, so i am wondering if this is the correct way of doing things.Īlso, when I initialize my game, I load numerous different Sprite objects from a TextureAtlas. I currently render the sprites using sprite.render(SpriteBatch batch). What I would like to happen, is when they are scaled, each pixel is scaled proportionally, keeping the pixelated effect on the button, rather than a blurry resized image from a really small texture. I use sprite.scale(int scale) to scale the sprites, but when I scale them, they appear blurry. When I render these buttons, on a canvas of 1920x1080, they are much too small. These images are supposed to be buttons, but as you can see, the image is very small, so when the sprites are loaded, they load a sprite of say, 34x16 pixels. My texture atlas image currently looks like this. I am loading my assets from a texture-atlas, which I packed no problem with the LibGDX texture packer gui tool. I am currently experiencing issues when drawing and scaling sprites. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |