I am using AndEngine to create a project game for school.
I am creating a Tiled map using Tiled. The problem i am having is that i cant figure out the size of the map it should be to fit all devices.
or is there a way to create the Tiled map to fit all screen sizes? If so please let me know.
As of now the TiledMap is to small on tablet devices and on cell phones it is to large.
Any suggestions or tutorials on this?
This is what i want to create. Not exactly like this but it is an example.
There's no built-in function for changing the tilemap resolution in Tiled.
Someone wrote a script to change the resolution of a Tiled map. This might help in making the Tilemap with two sets of graphics.
Generally speaking you should aim to support the two or three primary display resolutions. You may have to optimize the tilemaps for each resolution. An alternative would be to either display borders (assume a larger screen is as big as a slightly smaller one) or scale up the tilemap layer (that will most likely result in visual degradation). That means for the best quality you'll need to create one set of tilemap with the corresponding graphic assets for each of the device resolutions you want to support. There's nothing "automagic" about this.
Related
(if you want to skip all this text you can go straight to the "short
question" version at the bottom)
Hello, guys!
I'm a beginner android developer currently creating a 2D RPG game. It basically consists of a map where the player walks (in 8 possible directions - west, north-west, and so forth) and interact with objects, creatures and others. The player's character walking animation consists of 9 sprites per available walking direction, totalizing 72 sprites. I have these sprites both in individual .png files as well as in an organized sprite sheet.
Until some days ago, I've been using the individual sprites in the game. I would load their drawable ID into an int[][] array and then, when each frame was going to be drawn, I would decode (using BitmapFactory.decodeResource() method) the necessary sprite and pass it to my renderer class that would then draw it.
After some thinking, I decided to try and use the sprite sheet instead, since the constant decoding of the sprites images was bothering me. For that, I decode the bitmap containing the sprite sheet with all the needed sprites and store it into a member variable. Depending on the required sprite for the next frame, my program would crop the required sprite out of the sprite sheet (previously saved into memory), resize it according to the player's devices needs and then pass it to my renderer in order to be drawn.
The problem is, I can't tell which method is more efficient! While it's easy to measure how much memory the decoded sprite sheet bitmap occupies (when stored in a member variable) in the player's memory (approximately 4MB), it's hard to know how much memory my program uses for constantly decoding small bitmaps, that corresponds to the individual sprites. Does anyone have any insights on how I could make this comparison? Or perhaps can share a previous experience related to this subject? I have searched for hours and, despite having found much useful information on how to load bitmaps efficiently and suggestions for libraries (like Glide, Fresco, and Picasso), I still couldn't find an answer nor better methods. Thanks in advance!
SHORT QUESTION: Is it better to constantly decode small bitmaps or to just decode a large bitmap once and then crop smaller bitmaps from it as needed?
P.S.: I'm aware that both presented methods for creating the animations in my game are probably inefficient. But, for the sake of my learning (my primary objective for creating this game), I don't want to use game engines, like AndEngine and libgdx. I also started learning OpenGL ES (which I've read provides great tools for loading and displaying bitmaps), but implementing it into my game would require a complete remake, in which I'm not interested right now.
I have been trying to support multiple screen resolutions for Android, i have tried all the viewports but non of them fit my game well, my game is like Asteroids where the ship wraps around the world when it reaches the edge of the screen. if i use Fitviewport on some resolutions the ship wraps around before it reaches the edge of the screen and if use Fillviewport the ship goes out of the screen instead of wraping around, if i use Stretchviewport the game looks horrible the other viewports are not working well either, So i think the only solution for me would be to create diffrent assets for diffrent resolutions, now how do i go about doing that?
try using ExtendViewPort and provide the minimum and maximum viewports your app should support. The maximum size will limit how much the world is extended and the minimum how much shrink
I've never used LibGDX, but it sounds like your problem is with different aspect ratios, not different resolutions.
So if I were you, I'd try Fillviewport, and then I'd calculate everything manually to make sure to reset the location of the ship (and any other objects) to the other side when it collides with the edge of the screen.
This is not super easy, so this is why a game like PewPew will use a square frame for its asteroids-mode instead.
What is the best way to get around the max texture size in Libgdx? I currently have a 2048x2048 texture with an ortho cam zoomed in at 2x which serves as the "map" for my top down shooter. The problem is that 2048x2048 just isn't enough space for the player to move around in, so I need to expand the map without creating a huge texture. Am I going about this wrong? should I not just use a giant texture for the background?
Only some phones will support textures bigger than 2048x2048. This is a GPU hardware/OpenGL driver limitation and not the fault of LibGDX.
The most common solution is to build a map out of several smaller textures that can be repeated to create the illusion of a giant map. You don't just take the map of the world and divide it into 2048x2048 chunks, you instead have a bunch of tiles that are 32x32 pixels and represent things like grass, dirt, grass meeting dirt, etc.
This is why LibGDX has a maps package. See https://github.com/libgdx/libgdx/wiki/Tile-maps
Instead of trying to create the map programmatically you record the map in a text file and use a map loader at runtime. There are a couple of supported map formats. The best way to create the map files is to use a map editor like http://www.mapeditor.org/
I am developing a game using libgdx. Now i'd like to have a Background all over my map (Map size is not fixed yet i'll decide later). My map is tile based but i don't use TiledMaps. So i create and load the map with own code/editor.
My question now: How should i implement the background thing?
I thought about different ways:
Loading a huge Image, which covers all the map. This is not realy good cause i render things, which are not in my viewport (80 Tiles X,50 Tiles Y).
Deviding the Image in 4 or more Images and loading the one in the viewport. The Problem: At some point maybe part of all Images is in viewport so all Images are sent to GPU right?
Having 1 Image which cover the viewport (80,50) and follows the camera. Best performance i think, but it will look stupid...
Or every tile has an own Image and the Objects are drawn above them. Notice that i only render Tiles inside the viewport. But on Gamestart it would need to load Information about every tile in the level.
For Information: My Game is Topdown and the Background Shows the floor so no detailed hills etc are needed, just maybe some simple desert sand look and things like that. Is there another even better way?
What would be the best way for performance and optic?
If your game is Tile Based. It would make much more sense to have the background tiled aswell. Just use another layer for it. If your editor/loader does not support multiple layers, then I would recommend you to switch to another one, or add those features to it (if possible).
The Background Shows the floor so no detailed hills etc are needed, just maybe some simple desert sand look and things like that.
It is very easy to reuse tiles in something like a desert, because all their tiles are very similar (sand).
I know people asked how to support different sizes but they only cared about the dimensions of the images. My question is somehow different. I want to know if using pixels is a good way to scale everything and also to position images on the screen.
Is there a better way?
I am creating a 2D game BTW.
Regards,
Baracat
Another way that you can do is to having many sets of images at many resolutions as possible then load it dynamically depends on the screen resolution. I am using this method for menus in my 2D games.
EDIT:
For positioning please have a look at this thread