Tag Info

New answers tagged

1

This can easily be done just with the bounds of the screen and the position of the sprite. The screen bounds can be stored in two variables, screenMin and screenMax, where screenMin contains the minimum X position of the screen and the minimum Y position of the screen, screenMax does likewise with the maximums. leftDistance = spritePos.x - screenMin.x; ...


0

I would also be interested in hearing how other people manage their artwork in libGDX. I'm sure most users of libGDX will encounter this as soon as they try to use spritesheets from other sources (not made in-house, with libGDX in mind). I had the same issue, trying to use resources from OpenGameArt.org. I have solved this problem two different ways. ...


2

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


0

Since the GestureListener consumes all its InputProcessor events to transform basic events into gesture events. The best way would probably be implementing a separated InputProcessor to catch the touchUp(). You instatiate a new InputMultiplexer and plug it to the applications instead of the Gesture Listener, then you plug your new InputProcessor and the ...


0

The have their own site now. A bunch of tutorials and links can be found at - http://libgdx.badlogicgames.com/documentation.html


0

The simple way to draw in 3D is to wait until LibGDX has implemented their 3D functionality. Otherwise, you can simulate the effect in 2D. Basically, you change the scale of the object to represent its movement along the Z-axis. Rotating would only be with respect to the current 2D perspective.


0

use this code. Though you must have got a file named app.java when you downloaded .zip of physics body editor. This code is from that file only which uses .json file from the editor. // 0. Create a loader for the file saved from the editor. BodyEditorLoader loader = new BodyEditorLoader(Gdx.files.internal("data/test.json")); // 1. Create a ...


0

This is just speculation: Maybe you forgot to call act() on your Stage that has all the Actors. Actions are updated per frame through the act() method on each Actor which is called by Stage's act(). public void render () { Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); stage.act(Gdx.graphics.getDeltaTime()); stage.draw(); } From ...


0

If you'll keep the Pixmap object you'll be able to check for the alpha component in the relative location. Try the following code: final Pixmap pixmap = new Pixmap(Gdx.files.internal("brush")); Image brushImg = new Image(pixmap); brushImg.width = mStage.width()*0.75f; brushImg.height = mStage.height()*0.75f; brushImg.setClickListener(new ClickListener() { ...


1

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.


2

There is a bit of documentation on the Net package that gives a very brief overview: http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Net.html The Net.HttpRequest doc covers the http setup in a bit more detail. The http API is based on callbacks to listeners that handle results or failures. The raw Socket API provides stream-oriented ...


1

You can have the attached sprite be an entirely separate entity, and just have this entity be moved beneath the original entity each time this entity updates. If you were using scene2d actors, you could have the bottom sprite just be an actor that continuously executes the MoveToAction with a duration of 0, instantly moving beneath the upper sprite (actor). ...


1

There's a bug in com.badlogic.gdx.backends.gwt.GwtFileHandle that adds a slash before the image path in the atlas, but here is a workaround: Put the atlas files are inside a folder like "assets/images/", don't put it directly in the assets folder, and make sure the image path in atlas file is correct (relative to atlas), then it should work. Or you can ...


1

The quick and dirty way to fix this is to use InputMultiplexer. This allows you to pass those gesture events to both detectors. VirtualJoystick vjs = new VirtualJoystick(x, y, width, height, bgImage, fgImage); VirtualButton vb = new VirtualButton(x, y, width, height, upImage, dnImage); GestureDetector joyGestureDetector = new GestureDetector( ...


0

To point towards a direction you can use atan2. It is a very useful function that does a bit more than pure trigonometry to take case of sign of the answer. If you have a vector you wish to point in (V), then you can find the angle your sprite should be with: float angle = atan2( V.y, V.x ); Remember, this value will be in radians, so if you need ...


2

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


0

This is a basic linear algebra question. A vector is the difference between two points, such that A + V = B. You can find the correct V by taking B - A. If you need both a reference point and the vector, you need to store both of them. The combination of a starting point and a vector pointing to an end point is a line segment, not just a vector. You can ...


0

You have to overwrite the keyDown function in Stage. See this example code mStage = new Stage() { @Override public boolean keyDown(int keyCode) { if (keyCode == Keys.BACK) { Gdx.app.exit(); } return super.keyDown(keyCode); } }; Gdx.input.setInputProcessor(mStage); ...



Top 50 recent answers are included