Tag Info

Hot answers tagged

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


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

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

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

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


5

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


5

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


5

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


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


5

I assume this is because in these cases the grid lines are not exactly on screen pixels, but somewhere in between. Is this correct? Yes, this is correct. The camera in LibGDX is based on a vector, which is made out of floats. When your camera is in between pixels (like at (1.2f, 63.5f)), then you will start to see that blur you mention because the ...


4

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


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

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

The problem with naively rendering a small scanline texture onto a large full-screen quad is that the texture will scale up, making what was a set of single-pixel scanlines in the texture much thicker, blurrier (depending on your interpolation method), and generally uglier. You should instead tile the texture across the quad in such a way as to preserve a ...


4

Camera The problem might be the up vector of the Camera. This up vector is what determines the roll of the camera. As the camera rolls then what it considers up will change with it. You can set it directly to (0,1,0) using "mCamera.up.set(Vector3.Y)". This should fix the tilt. You are setting the camera lookAt using "mCamera.lookAt(...)" which may be ...


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


4

At the moment, you're moving the piece with a linear interpolation. That means that every timestep, the tile's position changes by the same amount. position = position + translation * timestep You could use any function there: position = position + translation * f(timestep) Then the position changes by an amount determined by the function f. There ...


4

Alright, so you're working with two rectangles here. A larger static one (the map) and a smaller moving one (the camera) inside of it. What you want is to not let the bounds of the smaller rectangle move outside the inner bounds of the larger rectangle. // These values likely need to be scaled according to your world coordinates. // The left boundary of ...


4

I tried it out in RUBE and the Prismatic joint works fine for me: What you may not have realized is that you can set joint limits on the prismatic joint, which makes this a lot easier to set up. You can tune this by playing with the mass of the block, and the linear damping. You might also want to set the coefficient of restitution to zero.


4

If you are using LibGDX, you need to forego the concept of Activities and Views, since your entire game will now just be a single Activity. To have a main menu when you game starts up doesn't switch the Activity, but just presents a different set of objects to be rendered to the same Activity. The easiest way to accomplish this would be to do the following. ...


4

So in general, JSON works really well for storing parameters and settings, but for storing big blocks of data like tile maps, you'll probably want to use your own format. JSON can be really repetitive, storing 256K copies of the string "GRASS_TILE", and that could be part of what's causing the slowdown. Using a SQL database probably isn't what you want to ...


4

It's easy: Fonts do not need to match resolution, they need to match pixel density. Pixel density is measured as pixels per inch(PPI), or pixels per centimeter. There's also a measure unit called density independent pixels(DP). 1dp is the size one pixel has on a 160 PPI screen. Now coming back to fonts, try to make this test: put your laptop to run on ...


4

There are three main ways (that I know of) to obtaining input in LibGDX. The first is as you said, changing the ClickListener, the second will be setting the setting the current screen as an implementation of InputProcessor , and the third will be obtaining the mouse click through a new class, or a sub-class to get the input. I'll elaborate on each: The ...


4

This is actually really simple. All you have to do is add another ClickListener which listens for Right Clicks (the default only listens to left clicks). To do this all you have to do is this: someButton.addListener(new ClickListener(Buttons.RIGHT) { @Override public void clicked(InputEvent event, float x, float y) { //do whatever } ...


4

I don't know if it is because of a poor component that causes the false readings or a extremely precise component that registers the spinning of the earth, as it orbits the sun, as our solar system spirals through the galaxy. Either way, this is a common problem. The solution is to use some type of filter to smooth out the "extra" readings. There are ...


3

The Facebook APIs are HTTP-based, so you can issue a HTTP post request from your game to the appropriate API endpoint (see "Publish a Post," which unfortunately has no anchor). The endpoint in question is me/feed, so you'll want to construct a request that looks basically like this: http://graph.facebook.com/me/feed?message="SCORES HERE"&access_token=X ...



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