Tag Info

Hot answers tagged

7

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

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

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

Gdx.file.internal is read-only. You can use local file or preferences (creates an internal .xml file where you can store small amount of data). It is perfect for game saving. Take a look at : https://github.com/libgdx/libgdx/wiki/Preferences You can also use an external file (stored on sdcard), but you can optionally encrypt it, as it can be edited by the ...


3

Simple Solution If you want the body to instantly rotate just call Body::setTransform and pass the current position and the desired angle, don't bother applying torques or anything. The function call could be something like this: body.setTransform(body.getPosition(),myDesiredAngle); Physics Solution If you want the player body to interact with bodies ...


2

Read the wiki! Controllers connects/disconnects don't give listener events (right now), so controllers must be polled manually. The wiki says controller listeners don't work on the desktop for connects or disconnects. I'm no expert, I've just been reading the wiki in detail, but it looks to me like you must poll the controllers manually. This code will ...


1

Have you tried a newer version of LibGDX? Support for GL 1 was removed a while ago so it seems that you're using an old version. It might fix the problem. If that doesn't work, can you show the rest of your code? Edit: Oh, and maybe change GL10.GL_COLOR_BUFFER_BIT to GL20.GL_COLOR_BUFFER_BIT Edit2: Okay, I noticed a few other things you can try. First, I ...


1

Of course there are many ways to do muzzle flashes for top-down games, and it's often subjective and depends on your situation. However, by far the most common approach I've seen is to simply use a texture that is shown for a very short time when the gun is fired. As an example, I'll use a game I made during a recent game jam, where I used the same ...


1

Keep rendering the game. just pause the logic! You can esily just attach a "pause" pass, that will render the framebuffer and then blur it or what not, and after that add some gui! should be really straight forward. The only reason i can imagine why you would like to take a screenshot is to not use all the gpu power and reduce lag when you are pausing. ...


1

Why don't you create a class for your coin object, and then collect all the coins in an array (Sprite[] coin), so whenever a collision occurs (player-coin), you call coins[i].destroy, where you can properly dispose all the referenced resources, or reset position for the next coin ? For drawing : for (int i = 0; i <= quantity of coins; i++) { ...


1

Thanks for the comments -- I finally understand what you want. TLDR: the summary of your question is encapsulated in the libGDX project setup page. Essentially, libGDX has you create one "core" project (which is a standard Java project). Within it, you have your main game code. Beyond that, you have wrapper projects (one per platform); these only call the ...


1

Sure. Take your camera matrix and unproject it (or invert it). This can be done in libgdx like so: Vector3 worldCoordinates = new Vector3(screenX, screenY, 0); camera.unproject(worldCoordinates); The documenation can be found here.


1

What your dealing with is an aspect ratio mismatch. Your trying to map an aspect ratio of 1 to an aspect ratio of 16:9 or 16 :10. That is why your tiles look stretched. Set your games resolution to a square aspect ratio like 300x300 if windowed. Or make your tiles about 160x90 pixels to look square at that resolution. Topics of interest would be ...


1

You should probably use texture regions. With texture regions you can select a sprite, doesn't necessarily have to be a sprite in your case, and slice it up in parts to be reused. As example: int numOfTiles_Horizontal = 3;//Can be any size as long as it lines up with the texture size. int numOfTiles_Vertical = 3;//Can be any size as long as it lines up ...


1

Trust me look into Scene2D. It handles everything input related for you. You can even do timed based actions on it, which are very nice. Its also built into libGDX. Truuuuust me its super easy once you get the hang of it. Honestly, I now write everything in Scene2D. If your having issues getting started with it, Heres a little sample code for you Stage ...


1

Bodies are made up of one or more fixtures and fixtures define a shape. This means, for each fixture, you need to get the shape and its size, then combine those to get the total width and height. It looks like the easiest way is with getRadius(), but that doesn't give you much. You may want to get the shape type, then create methods for getting more detailed ...


1

I finally got it !! package com.Main; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Screen; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GLCommon; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; import ...


1

Unsure if you found an answer, but for anyone else who came here looking for one: Setting Gdx.input.setInputProcessor(stage) basically means the stage is getting all input signals. So to get your events to fire, you need to change buttonPlay.addListener(new InputListener() to stage.addListener(new InputListener() and do that for the rest of your ...



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