Tag Info

Hot answers tagged

118

"Memory" and "efficiency" are commonly misused terms, so I'll give you an answer for four different elements that may affect the performance of your game. I will be oversimplifying way too many things to keep it short and concise, but there are tons of inaccuracies in this text below, so take it with a pinch of salt. However, the main concepts should be ...


25

Welcome to open source! As most developers will tell you: "What documentation?". Documenting code is probably the least fun developers have when creating a project. So what do you think is often severely lacking when the developer isn't even getting paid for their creation? Documentation of course! (Even fully paid programmers will often leave out the ...


19

As usual I'll just throw a few ideas to the table. There are certainly several ways you can approach this problem. I'll describe the three I managed to remember, and it's up to you to decide which (if any) of these approaches is good for your project. Idea 1: Repeatable patterns in your tiles Does your system need to be flexible enough to support any ...


17

I think you're after Application querying switch(Gdx.app.getType()) { case ApplicationType.Android: // android specific code case ApplicationType.Desktop: // desktop specific code case ApplicationType.WebGl: /// HTML5 specific code }


17

Once an image is loaded off the disk and is formatted for rendering, it will use the same amount of memory regardless of whether that image was saved to disk using PNG, JPEG, or GIF. General rule of thumb: JPEG is a lossy format, and will degrade image quality in order to make the image smaller on disk. PNG, on the other hand, is a lossless image format, ...


15

When the ball (red trajectory curve) hits a block higher up (blue rectangle), it will be moving slower than when it hit a block lower down (green rectangle). Hence why it doesn't bounce any higher than where it came from. Physically, this makes sense. Doodle Jump obviously isn't physically accurate. If you want an effect like in Doodle Jump where the ...


15

Think of the problem like this: How does a snake move in the original game? The snake moves towards its current direction. The behavior looks like the head appears out of nothing, and the last tail part disappears. You can have a list of snakeparts. What you want to do is remove the last item in the list which represents the last tail part. Then you want ...


14

As Byte56 said, in libGDX you cannot play videos :( so i did this: I created a new activity "SplashScreen" public class SplashScreen extends Activity implements OnCompletionListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); String ...


13

From my little experience with box2d in libgdx, it can sometimes be difficult to isolate and resolve issues with exceptions which was only worsened by the latest port. Pre 2.2.1, I could easily remove bodies from the world without synchronization issues like you are experiencing but after migrating to the libgdx build that supported 2.2.1, I started seeing ...


12

I agree with @Byte56 that you may be better off with something a bit simpler than Android game development, however for completeness (if other people would like to know where to look): http://steigert.blogspot.com.au/2012/02/1-libgdx-tutorial-introduction.html Steps through several different aspects of development with libgdx, from setting up your project, ...


12

It's basic physics: heavier objects don't fall faster! A feather has a bigger area than a pebble; hence it gets slowed down by air resistance a lot more. Introduce a drag force that slows down objects the faster they fall, in the opposite direction of the velocity. The drag force will cancel out gravity once terminal velocity has been reached. drag_force = ...


10

Create a triangle strip. You could have your random heights at intervals equal to t. So the triangle strip would then consist of you alternating between the height vertices (with y being random and x equal to t * iteration) and vertices that go along the bottom (with y being constant and x also equal to t * iteration). Naturaly, the distance between each ...


10

The reason you're limited to power-of-two sizes is due to how video ram works. Note that what you should do is typically make the image the next highest power of two (.e. 512x256), and then just use a portion of that image for your graphics. You'd be setting your UV coordinates to only use a subsection of the image onto whatever triangles you're rendering. ...


10

The PNG files are small because they are compressed. When the images are loaded into memory they are uncompressed and therefore take up more space.


9

Ignore all the /bin/ directories (they contain files generated from sources). The /war/ directory hierarchy is similar (generated files for the GWT/HTML backend). You can ignore the /.settings/ directories, as they contain Eclipse settings, and are not required to be able to re-build your application. (These are probably a bad idea to push into git if you ...


8

You can just use another SpriteBatch without setting projection matrix to draw the HUD, camera.update(); spriteBatch.setProjectionMatrix(camera.combined); spriteBatch.begin(); aButton.draw(spriteBatch, 1F); playerShip.draw(spriteBatch, 1F); spriteBatch.end(); hudBatch.begin(); //Draw using hudBatch hudBatch.end();


8

TiledMap tiledMap = new TmxMapLoader().load("path/to/tiled/map.tmx"); MapProperties prop = tiledMap.getProperties(); int mapWidth = prop.get("width", Integer.class); int mapHeight = prop.get("height", Integer.class); int tilePixelWidth = prop.get("tilewidth", Integer.class); int tilePixelHeight = prop.get("tileheight", Integer.class); int mapPixelWidth ...


8

You want a "Data Driven" system. This means that you have one game screen used over and over for every level. When you want to load a level, read a file to decide what to do, the code should not know in advance because you might want to send out new level files later (ala DLC). For this drop game, it would be pretty simple, your level file would probably ...


8

No, you don't have to use any specific toolset and you don't have to use any specific (physics) library either. It's just a question of convenience, since things like Box2D will provide you other benefits as well, e.g. being able to do collision, physics simulation etc. If you're not using tiles, you'll most likely want to write your own custom editor. As ...


7

I just started in libgdx (i have 2 weeks developing there). The pros, its that you dont need the emulator and you can test everything you do in the real speed, also if you know Java it would be easy (i know Android apps uses Java, but this is more easy, in my point of view), the architecture of libgdx for the game development is too well built. The ...


7

I decided to go with libGDX for similar reasons. To expound on my comment, I will mention what I find are the pros and cons. Pros: Works on Android and desktop (no need for emulator) Active user community on forums Lots of robust functionality Works on iOS too (via RoboVM => free) Cons: Lack of documentation and information Quite low-level (I prefer ...


7

I had to do something like this in XNA with pixel-art sprites. The best way i've found was using pixel shader. The sprites are done in gray-scale (8 bits colors without alpha), then you'll have to map each gray-color to the correspondent 32 bit color you want, using a 256 lenght array of Colors. In the shader you can use the gray colors of the sprite as a ...


7

There are a few potential problems here. Lets take a look at your code first: if(arg0>0) iX += 20; else iX-=20; arg0 is the velocityX of the last known horizontal velocity of the finger in pixels per second. Here's the method signature for fling(): fling boolean fling(float velocityX, float velocityY, ...


7

Obviously not a lawyer, so this isn't legal advice, but my personal interpretation is: The code is licensed under Apache License, Version 2.0. If you read the Redistribution section: You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form... So, yes, ...


7

It turns out my initial suspicions were right. The SpriteBatch draw method takes floats for the X and Y, so I decided to feed it my positions as is, kept as floats. WRONG. It seems that the SpriteBatch class can't round properly or something because when I cast all of the values to integers and then gave it that, everything turned back to normal and is ...


7

Option #1: Split tubes into 2 parts, the tube and the rim. So that you stretch the tube to be as long as you need it and the rim part is always the same size. Option #2: Make the tubes to be always the same length and hide the ends behind the walls.


6

Most APIs represent the Sprite's origin in local space, not in world space. This is supported by libgdx's documentation which states: A Sprite also has an origin around which rotations and scaling are performed (that is, the origin is not modified by rotation and scaling). The origin is given relative to the bottom left corner of the Sprite, its ...


6

As a new android game developer myself, I understand what you are trying to look for. I've researched on this for a while and I chose libgdx as a game dev framework. There can be several reasons. The developer of libgdx is also the author of "beginning android games". For some reason the author does rarely mention about libgdx in that book and I liked it ...


6

Since you can read the device density and render fonts during runtime in libgdx, I use this solution to achieve a density independent font size: float densityIndependentSize = origFontSize * Gdx.graphics.getDensity(); int fontSize = Math.round(densityIndependentSize ); BitmapFont font = generator.generateFont(fontSize );


6

You might find some of the demos I put together for Scene2D helpful. The main one is here.



Only top voted, non community-wiki answers of a minimum length are eligible