I load that with TextureAtlas and call TextureAtlas#createSprites("something"). I will get an array of AtlasSprites.I draw these as if whitespace was not stripped using sprite.draw(Batch batch), but also I have to reduce the size of the texture to the size of the world, so I use setSсale, but the texture is not reduced to the size of the world .So I decided to try through batch.draw(Sprite sprite, float x, float y, float width, float height) but it draws like whitespace is stripped. How to draw texture as if whitespace was not stripped and reducing its?
( Just FYI ) The draw
method of Sprite
, which you were using previously, looks like this:
public void draw (Batch batch) {
batch.draw(texture, getVertices(), 0, SPRITE_SIZE);
}
SPRITE_SIZE
is the number of vertices, and 0
is an "offset", and unfortunately there isn't a similar version of this which uses scaling, at least that I could find.
The absolute best way to fix your issue, assuming you have some sprites where you do want some transparency, is to recreate your textures with fixed alpha
values. You can do this in a variety of image-editors. This way your textures are loaded correctly the first time.
An alternative way is to set the Pixmap.Format
when creating your Textures
to be RGB888
rather than RGBA8888
. The A
stands for alpha, so you are changing the format of the texture to have no alpha value. ( Just FYI, the 8
's are the number of bits used for each color channel - Red: 8 bits, Green: 8 bits, Blue: 8 bits )
However, when using a TextureAtlas
I am not positive on how to set the texture's output format for your case. I know it takes the Pixmap.Format
of the Page
into account, but I am not sure how to apply this to however you have your atlas set up.
There is also a batch setting
batch.disableBlending();
This will actually cause the batch to run even faster performance-wise. So that's good. However, everything drawn this way will be affected.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.