Why LibGdx texturepacker doesn't pack images in order? - libgdx

I got these images and when I pack them they come in the wrong order, like the last 7 images or so go to the front and this messes it all up for me and I don't even know why.I have packed images before with no problems.

TexturePacker does not store regions in a certain order unless you specify that order using indices appended to the file names. The intended way to pack and retrieve an animation is as follows:
1) Name the source images with their frame numbers appended, for example:
run1.png, run2.png, run3.png, etc.
2) Pack them with TexturePacker.
3) After loading the TextureAtlas, retrieve a set of regions by name. For example:
animation = new Animation(1/15f, textureAtlas.findRegions("run"));
The retrieved regions will be in the order of the frame numbers that were in the source file names.

Related

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

Continuously refresh SVG from server coordinates

Say I have a web server that contains a table like this which updates/changes once per second. Table can be stored in static file, SQL database, or in memory because it's very small.
Table contains three fields with Object Name, X coordinate, Y coordinate. Table has the following data.
A, 22, 4
B, 12, 3
C, 6, 7
The table might be stored in a static file, a SQL database, or just in memory since it's a very small amount of data.
I want to render an HTML page on a web client that contains a PNG image background. Then continuously render three circles representing object A, B, and C over the PNG image based on their X Y coordinates once per second.
I want to avoid redrawing the entire HTML page once per second for performance reasons. What is the best way to dynamically update the HTML page without reloading the entire HTML page? I read that it might be possible to just continuously reload the SVG file and overlay that circle over a PNG but even the SVG file is quite bloated when I all want to transmit is the coordinate change.
Is this possible?

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 /.

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.

Stick Images together

I just tried to use Google Map Buddy to get satellite image from Google Map. This application first download small images from google map and then stick them together into new image. I had to wait about 2 hours to get images download my computer and it looks like it downloaded all images (22,194 images) but then the app told me that it cannot stick them together. When I started app again I though this app will reuse images on my comp but it start downloading them again. So I had to stop the process and ask you, guys, if you know how I can put that puzzle together.
The naming pattern of those images goes like this:
x=92651y=48130zoom=17.png
x=92652y=48130zoom=17.png
x=92653y=48130zoom=17.png
x=92654y=48130zoom=17.png
x=92655y=48130zoom=17.png
...
...
x=92664y=48131zoom=17.png
x=92665y=48131zoom=17.png
x=92666y=48131zoom=17.png
x=92667y=48131zoom=17.png
...
...
x=92689y=48132zoom=17.png
x=92690y=48132zoom=17.png
x=92691y=48132zoom=17.png
x=92692y=48132zoom=17.png
x=92693y=48132zoom=17.png
What can I do to stick them together programmatically using some simple scripting language? I have access to Mac and Windows systems and may be can install any simple scripting languages.
Thanks
You could use Python with Python Imaging Library (PIL).
First I'd make a list of filename and their coordinates. Extract the integer coordinates from the filenames with regular expressions and store them in a list of dictionaries:
>>> filename = 'x=92664y=48131zoom=17.png'
>>> imagePattern = re.compile(r'^x=(\d{5})y=(\d{5})zoom=17.png$')
>>> x,y = map(int, imagePattern.search(filename).groups())
>>> {'x':x, 'y':y, 'filename':filename}
{'y': 48131, 'x': 92664, 'filename': 'x=92664y=48131zoom=17.png'}
Having a list of dictionaries enables you to sort them according to either dimensions:
tileListSortedByX = sorted(tileList, key = lambda i: i["x"])
and also filter them:
fileListWhereX48131 = [tile for tile in tileList if tile["x"]==48131]
With these two operations you can easily imagine the for loops to iterate over tiles line by line.
The last thing you need to create a big empty image (with PIL) where you'll paste the small tile images into. Its size will be a multiple of the tile size.
>>> from PIL import Image
>>> bigImage = Image.new('RGB',(300,300),(255,255,255))
#creates a white 300x300 image
Pasting the small images into the big one looks like this:
>>> smallImage = Image.open(tile["filename"])
>>> bigImage.paste(smallImage,(0,0))
Hope you get the idea.
The process of "sticking images together" is usually called "stitching" or "mosaicing".
I found a list of many applications that do this on Wikipedia article - "Comparison of Photo Stitching Applications".
Edited: removed link to single app I found and replaced with wikipedia list of software.