Libgdx texturepacker doesn't pack all images - libgdx

When i run the texturepacker in libgdx i have the problem that it doesn't pack all the images in one big sprite sheet. If i for example have 4 images and it only packs 3 of them. Note that 2 images are the exact copies of eachother so maybe that has something to do with it.

LibGDX by default doesn't pack images which are exact copies. This can be overridden by setting alias to false in your configuration.
alias: If true, two images that are pixel for pixel the same will only be packed once. (default: true)
However, usually it is beneficial to pack the same images only once because it creates a smaller texture. You can still use both names when getting TextureRegion objects or creating Sprite.

Set alias to false in the texture packer settings.
Documentation here

Related

How to set a texture filter

How important is it to set a texture filter?
In the book Java Game Development with LibGDX in chapter 3 they set a texture filter.
When I load video assets with the assetmanager I can't convert a textureregion to a texture to set the texture filter.
But I can however set a texture filter on the entire spritesheet like so:
textureAtlas = assetManager.get("images/packed/game.pack.atlas") // all images are found in this global static variable
textureAtlas!!.findRegion("button").texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
How important is it to set a texture filter? Is this an ok solution? How can I get the textures from the atlas?
Textures always have a filter. If you don't set one, it will have the default filter of (Nearest, Nearest). This filter is appropriate for retro graphics (pixellated look). Otherwise, you'll most likely want to use (MipMapLinearLinear, Linear). If your game is mostly done and you've identified sprite drawing as a performance bottle-neck, then you can downgrade to (MipMapLinearNearest, Linear).
When creating an atlas using the TexturePacker, there is an option for texture filter, and if you set that you don't have to set it after you load the TextureAtlas in your game. You could also add a line at the top of your pack file like this:
filter: MipMapLinearLinear,Linear
Otherwise, if you want to set it on the atlas, it is fine with a single-page atlas to do what you did, and apply the filter using a texture reference from any of the texture regions, since they are all referencing the same Texture instance. But TextureAtlases can have multiple pages, so it would be more appropriate to do this:
for (Texture texture : textureAtlas.getTextures())
texture.setFilter(...);
Edit: To add settings to a TexturePacker build, put a text file named pack.json in the directory with the source images. You only have to add the settings that you want to change from the defaults. LibGDX can read simplified json that omits quotation marks for elements with no whitespace. So to just set the texture filter, this is all you need in the file:
{
filterMin: MipMapLinearLinear,
filterMag: Linear
}

How to set different images in WMS by zoom level in Geoserver?

How to set different images (same TIF with different size) for some zoom levels?
Two ways.
First, layer group and scale dependencies:
create N separate layers, associate each one with a different set of activation scales in their style (take the raster style, copy, add min and max scale denominators). See also the documentation
make each layer "non advertised"
lump them all toghether in a layer group (or if you are on 2.11, skip the non advertised bit above and just create a "opaque container" layer group)
Second approach, use image pyramid:
Download and install the pyramid extension
Put each file in a different folder, naming them 0, 1, 2, 3, ....
Point the image pyramid to the parent folder, it will automatically figure out the image resolutions and setup scale switches based on that
If that does not satisfy you, go and tweak the pyramid property file in the parent folder

Force certain sprites into only one image of the TextureAtlas in LIBGDX

I'm using TexturePacker to make a texture atlas. The result are 2 PNGs. I need certain images(sprites) to be deposited into only one of the pngs so I only have to bind only one texture to use in some shaders that I'm using. How can I force certain sprites to pack themselves at the same place and not dispersed randomly into the 2 PNGs?
Perhaps I've misunderstood your question, but you could just use texture packer twice, once with each set of sprites. Then you know which sprites will be in which png
You can create subdirectories within the directory of your source images and sort them into pages by placing them in different subdirectories. Each subdirectory will get its own unique Texture(s). The advantage of this method is that you have only one TextureAtlas to manage. The correct Texture will be automatically grabbed when you create sprites or get TextureRegions.
If you set flattenPaths to true, then you won't have to worry about what you name the subdirectories. If you leave it as the default false, then you must include the subdirectory name as part of the sprite name with a /.

libgdx TextureAtlas, and NinePatch's

I am making a simple game using libgdx. I have a TextureAtlas that has I ninepatch I am trying to use:
The image is saved as menu.9.png
I am using the following code:
Image bg = new Image(Room.iAtlas.findRegion("GUI/menu"));
bg.setBounds(guix-border,guiy-border,(border+radius)*2,(border+radius)*2);
batch.begin();
bg.draw(s,1);
batch.end();
The output is like this:
I really just have no idea what I am doing wrong, but it should be more like this(Except it would have the shapes on top of it, but I didn't add those):
(I created that by hand, i've never actually had 9patch working, and it doesn't have the ships because I didn't bother to edit those in)
It looks like your "nine patch" isn't being treated as a real nine path, and is being treated as a "degenerate" nine patch (I had a very similar problem earlier: Loading nine-patch image as a Libgdx Scene2d Button background looks awful, though I wasn't using a TextureAtlas which is supposed to be the solution.)
Basically, when Libgdx reads the nine-patch out of your atlas, its supposed to read all the meta-data that describes how to chop the image up into 9 tiles (see https://code.google.com/p/libgdx/wiki/TexturePacker#NinePatches). I see a couple places this could go wrong:
Your texture isn't a valid nine-patch, and the meta-data is being ignored. (Check with the Android draw9patch tool.)
Your texture packer isn't processing the .9.png file correctly. Check the contents of the .txt file for your atlas, and see if it has "split" entries associated with the "menu.9.png" entry.
The texture lookup is just returning a regular TextureRegion wrapper for the nine-patch region, and isn't wrapping it in a NinePatch object. Try using TextureRegion.createNinePatch to make that more explicit. (I'm under the impression that this isn't necessary, but maybe it is ...)

AS3 - Using sprite sheets to optimize my games

So, I'm trying to make my flash "games" run more smoothly. I am using individual PNG files for each of my objects in order to create player animations.
I've heard from some places that using individual files like that is bad.
I heard about using sprite sheets in order to compress data and reduce memory usage.
Maybe I have it wrong, but is there a way to merge all of my PNG images (with transparency) together in such a way that flash can continue to use the images individually?
I am really looking for ways to make my programs run more smoothly in order to be able to have lots of images on screen without much lag. Any ideas on how I can make things run better?
Here is an example of a tile based game I'm trying to make that is having serious lag issues.
TexturePacker allows merge png files. It generates two files: png and config file. Png is just merged images and config file is txt file which you can load into your swf, parse and demerge your images using it. Config could be in various formats for different game engines.
Using Photoshop or similar software you would combine all of the animations frames into one file. The size and shape of the file can be whatever you want, but each of the 'frames' should be the same size, in the same order and with no space between them. For example, lets say each frame is 25x25px, your walk animation is 10 frames and you want the final .png to be one long strip. You would make a new .png with the dimensions of either 250X25 or 25X250 and then insert all of your frames into that one file in the order of the animation. It's up to you if you want to embed these as display object or files that get loaded, but once you have them you just need to use BitmapData to break up the input file into new BitmapData objects and then display them as needed. Going one step further, lets say that most if not all characters have a walk animation and an action animation, you would make a single class to deal with loading character animations and the first row of the image file would be the walk animation and the second would be the action animation.