![]() ![]() You might have to adjust the offset calculation depending on the pivot point / origin in your graphics system. Screen.draw(sheetImage, posX+offsetX, posY+offsetY, width, height) SpriteSourceSize gives you the offset for drawing the image - the parts of the image that are left out because of the trimming:Ī simple pseudo-code drawing routine looks like this: drawImage(spritename, posX, posX) The frame gives you the location of the original sprite in the sprite sheet. The important parts are frame and spriteSourceSize. ![]() The result is that you now get 2 files: The sprite sheet and a JSON description file. Pixel format: INDEXED 8bit - to create 8bit PNGs (about 70% less memory).TrimMode: Trim (this creates rectangles).Data format: JSON hash (or XML if you prefer that).Now drag the images on TexturePacker and select the following parameters You need this for aligning the animation. This is why there is so mich empty space above. Keep the original position of the bird in the images. You should split static and moving parts: I've placed a bird on a house to demonstrate this:īasically packing the complete animation into a sheet is a big waste of memory. In the original image, only one part of the image was moving. As promised won't make them public here so I've created some art myself to demonstrate how to reduce the memory usage. the free version might already suffice to create the sprite sheets for youĭo you use a game development framework like AndEngine, Cocos2d-x or LibGdx? => Noneĭo you need all your images loaded at the same time? It sounds like you'll run into massive RAM problems on the target devices.you can create a file data files that contain the name + position of each of your buildings.use indexed PNGs which consume way less memory - up to 70% less compared to a standard PNG file you can apply different compression - e.g.you can simply drag and drop all your images and get them packed.I would propose that you try TexturePacker Lastly, you might also be interested in thinking which types of image to use for each situation: Which image format is more memory-efficient: PNG, JPEG, or GIF? See this past answer that became a wiki of this site: īut also keep in mind that each type of compression may be more or less advantageous depending on the image file type you use:įor more details on compression: State of the art in image compression? Then when the game is running you either decompress or pull the desired image from the compressed file - depending on the compression format you use. ![]() This can often be very helpful to save disk space. Of course, how much it could help depends on a case-by-case basis and you should test to see if that can be of help to you depending on your images.Ģ) to compress the resources folder. In this example, saving each in 4 different PNG files amounts to 1255 bytes, while the single file with all concatenated is 451 bytes. So instead of saving 4 separate files for each of the following colored squares, I save all of them side-by-side within the same image (and will only split them via game code): That said, in a similar situation, two solutions I have seen (and used once) in terms of saving space in the disk, were:ġ) to concatenate individual images within one same image. If you are only interested in knowing about animation techniques that might allow you to save disk space, please let me know then I might delete the answer. So, I will put this answer here trying to be of help in relation to saving space when you have a lot of images. It's not clear by your question if you really want to know techniques that allow games to save disk space even when having large amounts of heavy image/resource files (that's what is in the body of the question), or if you just wanna know if there are less disk-space hungry ways of doing animation for your buildings (that's what is implied by the title of your question). ![]()
0 Comments
Leave a Reply. |