Tag Info

Hot answers tagged

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


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

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


6

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


6

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


5

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


5

Is your tiled map isometric or it is orthographic ? if it is orthographic use orthographic tiledmap renderer . More specifically, change renderer = new IsometricTiledMapRenderer(map, 1f/50f); to renderer = new OrthogonalTiledMapRenderer(map, 1f/50f);


5

Disclaimer: I have not used libgdx or Java before, this answer borrows syntax from the question and official documentation, and the code is untested To make the bodies 'fall' under the influence of gravity in box2d, you must first pass a non-zero gravity vector to the b2World when constructing the world World world = new World(new Vector2(0, -10), true); ...


5

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


4

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


4

Roy T. suggested to fix this changing the texture filtering settings, On LibGDX this can be found on Texture.setFilter or changing the Texture Params if you are using the AssetLoader. Set the filter params to TextureFilter.Linear and the problem should be fixed. For more on the matter, take a look at ...


4

I think you're conflating render and logic updates. The delta returned by the Gdx.graphics object is an elapsed time value that probably should only be used for render updates, but the state an object is in is more of a game logic issue, and you generally want these things handled on different timers. This is because if you pause your game logic (by ...


4

The "Couldn't load file" error message you see is caused by two possible things: The path is invalid (probably this one) The file format is not supported (rare, but possible what OS are you using? I have seen this with Macs) First, check if the path is truly correct. Check this: Gdx.app.log("AssetPath", ...


4

in general, if you're going to remove items from an ArrayList, you're going to skip over stuff with the pattern. for(int i=0; i<list.size(); i++) if (something) list.remove(i); You should get better results iterating backwards while removing so the indices don't shift, or simply decrementing 'i' when you delete: for (int i=list.size()-1; ...


4

I was able to find a solution, in order to convert the mouse coords to the coords relative to the tile map, i used: @Override public boolean mouseMoved(int screenX, int screenY) { //screenX, screenY - Mouse Coords Vector2 centerPosition = new Vector2(player.getX(), player.getY()); Vector3 worldCoordinates = new Vector3(screenX, y, ...


4

You are setting up the depth test correctly. Note that the backface culling is not needed for this case, although it's still good to enable for other reasons. A likely reason why your depth test is not working correctly could be using 0.0 as the near plane when calling gluPerspective. See ...


4

First, Texture vs TextureRegion: When you do something like Texture t = new Texture(path), you are loading that into GPU. In addition, you should load power of 2 textures. You could work with other resolutions (Texture.setEnforcePotImages = false), but it's encouraged to use pow of 2. Now, TextureRegion, takes a "piece" from a Texture, no matter it's ...


4

I'm guessing you have 64 bit java installed. The ParticleEditor.jnlp fails to run on a 64 bit JRE. What you would want to do is: Download a 32 bit version of JRE. Here is the Oracle link for that: http://www.oracle.com/technetwork/java/javase/downloads/java-se-jre-7-download-432155.html Just make sure you select a "x86" version of the JRE from the list, ...


4

The particles themselves associated with a particular effect shouldn't be tied directly to the object. While there is never a 100% use-case scenario, this still applies to most situations. Your object itself shouldn't be managing the life-cycle of a particle effect, though it may be the instigator for spawning particular effects in the world. So, in your ...


3

I don't use GestureListener, but rather track fingers in my own InputProcessor overrides. This allows huge flexibility, and gives me a rich set of input data, without worrying about some of it being stolen by another listener. I can't make out exactly what you're trying to accomplish, but by doing something similar, you can do just about anything. The ...


3

All vectors 'start' at the origin. They are just directions. You can define a ray, which is two vectors together, one to define position (P) and one to define direction (D). Then you can find any point on the ray by using a scalar parapeter (t): point_on_ray(t) = P + D * t By anyway, from the sound of it that's not what you need. In your case, you just ...


3

Although that's a little bit late, I'll still try to answer. From the ShapeRenderer javadoc "The standard use-pattern looks as follows:" camera.update(); shapeRenderer.setProjectionMatrix(camera.combined); shapeRenderer.begin(ShapeType.Line); shapeRenderer.color(1, 1, 0, 1); shapeRenderer.line(x, y, x2, y2); shapeRenderer.rect(x, y, width, height); ...


3

Here is a method I use for working with a single batch: First draw everything else, then draw your HUD last: Matrix4 uiMatrix = cam.combined.cpy(); uiMatrix.setToOrtho2D(0, 0, WIDTH, HEIGHT); batch.setProjectionMatrix(uiMatrix); batch.begin(); If you want to draw more after, make sure you reset the projection matrix to whatever it needs to be.


3

You probably did not include the icon in your jar file, or you did include it, but not in the right location. From the console, run jar tf Trace.jar to get a list of all files that are actually included in your .jar file. Check if there is an entry for the given path, namely src/trace/game/core/game.jpg If it is absent you'll have to configure your IDE ...


3

Did you find out which part of your game loop is it slowing down on android? Is rendering or logic, or both? You should profile exactly which part is slowing down and narrow it down. Assuming you profiled every damned part of your code and you can't find what's making it slow. Then, on andorid, one possibility is garbage collector is taking a chunk of time ...


3

As far as I know the framework, you code your game once, and it automatically creates an executable for all the platforms. So if you only want to make the game for Android and iOS, you only export the executable for these platforms and ignore the other platforms. The game also isn't made in the 'desktop' project, it is made in the main project. The ...


3

I think you should try Gdx.input.getX(i) and Gdx.input.getY(i) From the Gdx.input source: /** @return the last touch x coordinate for the first pointer in screen coordinates. The screen origin is the top left corner. */ public int getX (); /** Returns the x coordinate in screen coordinates of the given pointer. Pointers are indexed from 0 to n. The ...


3

i didn't read all of your code but if i get it right you want a curve movement. in linar algebra you can use vector addition for velocity and acceleration of object lets say : my_pos = (0,0) velocity = (1,3) acceleration = (0,-1) //gravity? do(lets say every half a second?) { to_move_x =velocity.x + acceleration.x to_move_y ...


3

But I need to use images in the game as body... not shapes.. In Box2D, you will need to create shapes anyway, you can't really go without them. A body is composed of fixtures and a fixture is a shape, that's it. Here is the official Box2D manual if you want to read more about those concepts. anyone please explain me the steps to use images as a ...


3

You could use a frame buffer object (FBO) -- basically think of it as "render to texture". You render your scene to the buffer rather than the screen. Then, after the scene is done you render simpler things like quads to the "real" screen, using the FBO as a texture sampler in your shaders. This means you could render multiple quads each using some subset of ...



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