Tag Info

Hot answers tagged

26

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


22

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 }


20

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


18

Storing the completion information in a local file is a simple and perfectly acceptable method of doing so. Fundamentally, this is what every game will do to track progress (in some fashion, although the specific formats used for the data and the storage mechanism will differ). Protecting the file from tampering is more difficult. If there's no compelling ...


16

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


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

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


11

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


11

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


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

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();


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

It defaults to locked on "landscape" mode in a libGDX project. You need to go into your "AndroidManifest.xml" and change android:screenOrientation="landscape" too android:screenOrientation="sensorLandscape" There are more options - http://developer.android.com/guide/topics/manifest/activity-element.html#screen Just replace "sensorLandScape" with the one you ...


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

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


9

You can create a replay file as proof of work while the player is playing. Start the game, save the starting conditions including the name of the level and the pseudorandom seed, record the exact timestamped input states (mouse movements, key or button presses, etc.) that your game's input layer passes to its logic layer, and stop recording once the ...


8

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


8

First off, what is the difference between say Body.getWorldCenter() and Body.getPosition(). Body.getWorldCenter() is the center of gravity. Body.getPosition() is the center of the AABB. For a simple box or circle they will be the same however if your body is unbalanced (ex. multiple fixtures /w different densities) they will differ. Also try setting ...


8

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


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


8

Here's a vector-based solution. I haven't tried it, but it seems fine conceptually. Theory I gather you've stored the shape as line segments. Here's the letter A represented with three line segments. I've assumed that paths in the user's drawing are stored as lists of points. We can "inflate" those line segments to allow an error margin when checking ...


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

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


7

Playing video with LibGDX has been defined as out of scope for the project. So no, you cannot play videos using LibGDX. This does not preclude the possibility of writing code specific to Android to play videos though. It just means your application won't maintain the portability of LibGDX.


7

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


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



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