Tag Info

New answers tagged

1

There are ways to do dynamic lighting without shaders, although they're usually not as efficient. They often involve raycasting. The link below has some links to useful resources regarding dynamic lighting. http://www.java-gaming.org/topics/2d-dynamic-lighting/27012/view.html


1

On LibGDX you have a so called InputProcessor public class MyInputProcessor implements InputProcessor { @Override public boolean keyDown (int keycode) { return false; } @Override public boolean keyUp (int keycode) { return false; } @Override public boolean keyTyped (char character) { return false; } ...


0

Found an easy solution to the problem. I just compared the midpoint x-coordinate of the player to the x-coordinate of the intersection to see where the player was relative to the platform (i.e. left or right). If the x midpoint of the player's rectangle > x point of intersection rectangle, then he should be on top - otherwise, he's on the side of the ...


0

You simply need to define the water, the same way you define the skies for lighting purposes. You may or may not need to duplicate the world simulation for lighting if you want water to behave different from solids.


0

Yes, there is a trick you can use here. Based off of your glitch and your code sample, I'm assuming that you're moving both the player's X and Y position at the same time, then checking for collision. Instead, move the player by its X velocity, then check for collision. If it has collided with any platform, then it must have hit the side of a platform. ...


0

Ok, I found a way. I'm not sure that it's the most performant, but it works, and the DEPTH_TEST (z-culling) is working now. Here is how I did it: in declarations: private ModelInstance mLattice; in create(): ModelBuilder modelBuilder = new ModelBuilder(); modelBuilder.begin(); MeshPartBuilder meshPartBuilder = modelBuilder.part("lattice", GL20.GL_LINES, ...


0

assert is your friend, if you get NullPointerExceptions that originates in your code (and not deeper into nested calls) then one of your objects is null, no matter how unlikely or impossible it seems. You have to assume that all assumptions are wrong and either step through the code and checking variables as you go, or - if that is hard due to the program - ...


0

Try this private long time; public void show(){ //... time = System.currentTimeMillis(); } public void draw(){ //... if(System.currentTimeMillis()>time+3000){ time = System.currentTimeMillis(); System.out.println("called after 3 seconds"); //change texture } } So you can change your Sprite's ...


0

That happens in native body creation, and in your code only these lines are directly connected with that: BodyDef bodyDef = new BodyDef(); bodyDef.type = BodyDef.BodyType.DynamicBody; bodyDef.gravityScale = 0.5f; SetBody(app.world.createBody(bodyDef)); Box2d manual recommends to set body positions from the beginning, avoiding putting multiple bodies to ...


0

Since your value is a float, you can just pass it to String.format String.format("%.3f", floatValue);


0

Apparently it is not possible to render semi-transparent cursor pixels under Windows. The workaround seems to be to hide the default cursor and render your own... (I am happy for better ideas though.)


0

Try to think about what happens when the objects overlap by a bit. This is the usual reason for such behaviour. Most likely the issue is in the part where collision is worked out and the force after collision applied.


0

It doesnt work, because you dont count fingers on screen, so no matter how many fingers will be on screen, touchDown always returns first touched coodrinates, next touches are ignored. If you want to use multitouch, then you have to make use of pointer variable in touchDown method. Actually i answered very similar question once in stackoverflow, and im sure ...


1

I think the only way to achieve a good result with Box2D is scaling things down. I use two OrthographicCameras for my games, one for HUD stuff and another to Box2D related stuff. Also, I use methods for scaling images and elements down. Here's an example of what I'm talking about. (It's not a working example. Just illustrating...) private final float SCALE ...


0

It's probably simpler to set boundaries on the camera set: camera.position.set(clamp(player.getX() + (player.sprite.getOriginX()), minScreenX, maxScreenX), clamp(player.getY() + (player.sprite.getOriginY()), minScreenY, maxScreenY), 0);


1

in drops.update: @Override public void update() { pos.add(direction); //add the speed difference for the next update direction.add(new Vector2(0, -acceleration)); if (pos.y <= -TextureManager.DROPS.getHeight()) { float x = MathUtils.random(0, ManicMeltdowns.WIDTH - TextureManager.DROPS.getWidth()); pos.set(x, ...


0

Seems like buildSprite is broken indeed. The freeBubble sprite is created with a different constructor, which seems to be the only difference between a properly drawn sprite and those made by buildSprite. Sprite's javadocs state that its parameterless constructor gives you instances that need more than just textures to be set. On the contrary, calling new ...


1

LibGDX has Viewport, which helps you do exactly what you are trying to achieve. You use the Viewport to specify where the Stage should be drawn and how big it is. The Viewport does not change the local coordinate system of the Stage itself, so you don't have to add an x offset to everything you want to include in the right hand stage (everything starts at ...


0

So the solution I found: 1. Re-build the project with GDX setup 2. Import project 3. added the following to the build.gradle in the project root under the "android" dependencies and the "core" dependencies section. 4. clean project 5. Select all gradle projects, right click on them, gardle->refresh dependencies That sorted it for me... ...


0

I am having the same problem. It is a dependency issue... I am very poor in knowledge of dependencies. I can make it work by using eclpise, right click on android project, properties, java build path, libraries tab, add external jars. But this wont work on android device... I think i am close to an answer though.


0

If by clear you mean set all the pixels to transparent you could do the bellow. Pixmap.setColor(Color.CLEAR); Pixmap.fill() http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Pixmap.html#fill-- http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Color.html


0

One way to align it back is to check it's current orientation. float bodyAngle = body->GetAngle(); Compare it with the desired angle: float delta = desiredAndle - bodyAngle; Then use applyTorque with a tiny amount to slowly increase the speed in that direction If the angular speed is too high, stop increasing the speed: if (delta > SMALL_ENOUGH) ...


0

Got the Problem. Looking at the source of ModelInstance this part shows why it can't work: public ModelInstance (final Model model, final Matrix4 transform, final String nodeId, boolean recursive, 128 boolean parentTransform, boolean mergeTransform, boolean shareKeyframes) { 129 this.model = model; 130 this.transform = transform ...


0

the code above works but change camera.setToOrtho(false,width,height); to camera.setToOrtho(true,width,height); it was just that i had a resize method and had in it camera.setToOrtho(false,width,height);


0

If you draw your "player" using screen coordinates, you will not have to project them. Screen coordinates range from (-1, -1, -1) to (1, 1, 1). (0, 0, 0) is the center of the Viewport and the coordinate system created by batch.setProjectionMatrix(camera.combined). Using screen coordinates, View, and Projection are Identity and, so, can be omitted. You can ...


0

How big or small are your objects? Maybe the problem is with float precision? This would explain that the problem does not occur when you are not using PPM


0

You can easily clamp the camera position to the map boundaries like this: camera.position.x = MathUtils.clamp(camera.position.x, camViewportHalfX, mapWidth - camViewportHalfX); camera.position.y = MathUtils.clamp(camera.position.y, camViewportHalfY, mapHeight - camViewportHalfY);


4

There are several different options for handling what you are attempting: These are not all or nothing solutions, you can mix and match them to balance the workload between programming and creating animations. Option 1 Can be used on a case by case basis. Obscure it. The transition between animation states can simply be hidden behind various effects. Blood ...


0

The problem is here: } else if (type.equals("NEXT") && player.getxPos() > SCREEN_WIDTH) { Granted that loadLevel is run at the start of your game, it will run and finish well before player.getxPos() is off the screen width. It will only check once when the level is initially loaded. You need to be able to 'stop' reading the file at 'next', and ...


0

If you want to draw the sprite in the exact center, you have to take the sprite's height and width into account. Assuming your viewport's width and height are set equal to the device's width and height. You can set the sprite's position this way sprite.setPosition((viewportWidth - sprite.getWidth())/2 ,(viewportheight - sprite.getheight())/2 );


1

Your problem is that the physics library, probably Box2D, supports only convex shapes. You are passing in a non-convex (concave) shape, and what you get as a result is that the convex hull of your shape is used as collision body. To avoid this, you can either manually make sure your collision primitives are convex, or you can triangulate the polygon (there ...



Top 50 recent answers are included