Tag Info

New answers tagged

0

Friction coefficient is equal to tangent of the maximum angle before the item will slide. You need to set coefficient greater then 1. There is a function in the Settings class - MixFriction. It's used to calculate the friction coefficient between surfaces, by default it's a geometric mean, you can change this too.


1

NEW ANSWER Found it. In the method setZIndex(), this line is the one that moves the children: children.insert(index, this); So the Z index is not a "true" z index which represents the depth, but the index of the children in the parent's children array. So if you try to put a child at position 3 in the array when there are only 2, it will be put at the ...


1

Your car is slipping for the same reason that a car hanging up-side down, riding the ceiling, with 100% friction would slip. 100% friction roughly means that 100% of the force exerted via the wheels on the terrain is used to counter movement perpendicular along the normal of the terrain. But this force still isn't enough to counter the force of gravity. This ...


2

This is less a problem with Box2dLights, and more a problem with setting up Box2d collision fixtures to match your sprites. The Box2dLight rays are colliding with the CircleShape fixture you attached to the box2d body. CircleShape chain = new CircleShape(); chain.setRadius(10); Instead, this should be a Polygon shape with the same dimensions as your box, ...


0

What I would likely do is convert the rectangle to a Pixmap, then, assuming the rectangle has a solid single color border (with a different color than the rest of the rectangle), I would simply iterate through the pixels in the Pixmap looking for the border color and save all the positions to an array. Then all you would have to do is periodically set the ...


1

Copied from here: http://stackoverflow.com/questions/15733442/drawing-filled-polygon-with-libgdx Basically, you define a PolygonSpriteBatch using a PolygonSprite and a PolygonRegion: PolygonSprite poly; PolygonSpriteBatch polyBatch; Texture textureSolid; You then create them like this, giving the region a texture and the 4 corners coordinates (for the ...


0

This approach works well for LibGDX 1.2.0 First of all you must create new instance of DebugDrawer and set debug mode you need: debugDrawer = new DebugDrawer(); debugDrawer.setDebugMode(btIDebugDraw.DebugDrawModes.DBG_MAX_DEBUG_DRAW_MODE); Set this drawer to your btDynamicsWorld instance: world.setDebugDrawer(debugDrawer); Display debug data in ...


1

Why not using Actions.forever(Action repeatedAction) ? Example : fadeLoop = Actions.forever(Actions.sequence(Actions.fadeOut(time), Actions.fadeIn(time))); this.addAction(fadeloop)


3

For your first question you can optimize your method by only checking collisions with the border bubbles (only the bubbles that are actually exposed and not ones that are entirely surrounded). However, you can optimize this even further by using the fact that you know the coordinates of the bubble to find out approximately (or precisely, with some math) ...


2

pretty new to libgdx but i dont think it would be too hard to implement your own version of a "master volume" just have a float variable called master volume and then use it when ever you play your music and edit it how you please for example public static float mastervol = 1f; //playing your sounds sound1.play(mastervol); sound2.play(mastervol); ...


0

My question is how to get current time that is not taken from android settings to prevent cheating? I want to prevent the player from cheating by changing android time from settings. I see only one workaround, get a timestamp from the internet. Here for example : http://currentmillis.com/api/millis-since-unix-epoch.php Of course that would force your ...


1

So you need to call renderer.setView(orthoCamera) to reset the tile map drawing view. Then don't forget to also call camera.update() after you do anything to it.


0

Adding another Stage as a HUD(I couldn't Access the lower stage anymore or the other way around) It's the solution i'm using, and for me it's working fine. Assuming that by "couldn't access" you meant you couldn't handle input, you have to know there is a solution for this : InputMultiplexer. It allows you to handle event for multiples scenes and/or ...


1

If changes happen in an area, then you only need to update that area (rather than updating the entire map.) You could divide the array into an 80x60 array (I'll call them 'chunks'), each with 10x10x3, sections. With some basic data on who owns each larger section. So if the raising/lowering only happens in adjacent fields, and you know that all chunks ...


0

If you're looking for a really simplistic approach, here's one I've used in the past: Create an object that has both sub-objects (rectangle and circle) Create a getter/setter pair for x/y coordinates on your object When you move the object by calling setX(x), it sets the rectangle's x coordinate to x, and the circle's x coordinate to x + a where a is the ...


1

Your MyGdxGame class' render method doesn't do anything. It should call GameScreen.render() to render. Some comments about style: Variable names should be lower-case on their first letter (gameScreen not GameScreen) Please fix your formatting next time Suppressing warnings should be done carefully; they're usually indicative of a problem that may bite ...


0

Not sure, but something really seems odd to me in your code. In your launcher you have : config.useGL30 = true; And then you are doing : Gdx.gl.glClearColor(1F, 1F, 1F, 1F); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); But since you want to use GL30, you should probably do : Gdx.gl30.glClearColor(1F, 1F, 1F, 1F); ...


0

assuming by sprite you mean that it is an image (loaded from a bitmap): i would iterate through the pixels in the image, and identify the ones on the edge (adjacent to a transparent pixel) (or load an identical black and white hollow rectangle image showing only the edge points for easier identification) log those Points into an array by starting at one ...


0

From one of your comments I saw that you meant to disable the navigation bar. Well this will keep it out of the screen until you swipe down from the status bar. It's the same code that Jetpack Joyride uses: View decorView = getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; ...


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


1

Although libgdx largely abstracts away the OpenGL component for most of the basic things, you can still use it in your code for the more advanced stuff. Usually though, if you dig a round for a while you'll probably find that about 99% of the time whatever you want to do with OpenGL has already been implemented somewhere in libgdx. Source: ...


1

You seem to want to keep the same textsize/screensize ratio. Basically what you do is develop at one resolution and let that be scale 1.0. Then you divide the new screen width by the old width and that is your scale factor. For example. Developing on 2560x1440 with font size 16 and running on 1920x1080. Font size will be: 1920/2560 * 16 = 12 I do the same ...


3

This logic goes in your update function rather than your render function. The easiest way to prevent this is with an if statement surrounding your stage interaction code. If (overlay not active) Stage.handleinput() Else Overlay.handleinput() Endif


2

After 3 days of working I managed to work around it, I created this git repository so people can use it, it says everything there. Git Repository Enjoy, those who need it. EDIT: Not the solution. EDIT: The solution is located here.


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

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


2

On the second table, you have two rows with three columns. If you want to center your others rows with these one, you have to set the horizontal size of the cell to three columns using the colspan method. The "center" method will only center the widget inside it's own cell. For example, your code should be : changeOptions.center().bottom(); ...


0

I pretty much find the source of the problem. When i was launching the game, the memory of the game was litterly growing every second (+10K Ko / s). I isolated the problem and the source of it is this "part" of code : protected boolean collisionInEntity(float x, float y, float xObject, float yObject, int collisionHeight, int collisionWidth) { Rectangle ...


2

So what I had been thinking has been confirmed: The dialog is built with a single NinePatch so you need to adjust the size of the title bar manually within the .atlas file and .png file. EDIT This will basically be a little How to use a JSON file with LibGdx tutorial. LibGdx has a very useful Class called Skin. It allows you to have a .json file along with ...


1

First thing: I see that you are using a stage from scene2D. A better way to go about this pause button is to use the scene2Dui class TextButton. You can customize it with a pixmap to make it look pretty much the same. As for your current problem, I am speculating that the problem might be that the ClickListener doesn't detect the mouse release because you ...


0

Try using this Camera:unproject method: unproject(Vector3 screenCoords, float viewportX, float viewportY, float viewportWidth, float viewportHeight) from the documentation: Function to translate a point given in screen coordinates to world space. It's the same as GLU gluUnProject, but does not rely on OpenGL. The x- and y-coordinate of vec are assumed ...


0

It doesn't make sense using this initial scale in this example, where it is equal to 1, so you can just delete it but it is useful when your scale is dynamic.


0

I think libGDX has a default joystick implementation. Check out scene2d.ui Touchpad


1

Try to extend the whale as an Actor and add an ActorGestureListener to it. Use the pan function to drag the whale. It will be something like this: void pan(event, x, y, deltaX, deltaY){ myWhale.position.add(deltaX, deltaY); } And I think you'll have to use Stage for that, but I'm not sure.


1

You could try and set the bounding box size depending on the sprite size. If for some reason your sprites(animation frames) have different sizes, then use the largest one's size.


2

It is drawing the bottom-left corner of the texture at the given coordinate (x,y). In the first case, it works because Link's body has an edge to the far left and so he appears inside the box. In the second case, however, the far left side of the texture is the end of the sword, so it places this part in the box and "draws out" from there. One possible way ...


0

You might also be interested in using vectors graphics. Vectors graphics use mathematical functions to describe objects rather then normal pixels. As such vector graphics are always as good as they can be on a given screen no matter how much you zoom in or out. You can look here for a number of software programs to generate vector graphics, now not every ...


0

Is it possible that you're tracking location in two different places? I noticed in your code shapeRenderer.begin(ShapeType.Filled); shapeRenderer.setColor(Color.RED); shapeRenderer.rect(rect1.getX() + (rect1.getWidth() / 2), rect1.getY() + (rect1.getHeight() / 2) - 2, rect1.getOriginX() - 1, rect1.getOriginY() - 4, 1.0f, 1.0f, rect1.getRotation()); ...


3

You can't render a rounded shape perfectly on a computer screen; a computer screen is composed of discrete cells (pixels) so some approximation is always going to happen. It's just a matter of hiding that approximation so the result is visually appealing enough. Nearest texture filtering is generally not what you want to create the appearance of smooth ...


1

To anyone who had run into this problem, it originates from the creation (at least for me) of another TTF file in the local directory (I.e. "myGDXGame-desktop"), and this causes a problem with the loading of the font. Make sure that this line, that is the save directory for the .fnt file, is not saving as .TTF This was what's needed to be made: FileHandle ...


2

I had a similar issue on Android with LibGDX a few month ago. Not sure if it is related though, but that's obviously something one should be aware of. A common issue : On low cost devices or old devices, when the size of the original texture file was superior to 2048*2048px, the texture won't load. And on the worst devices i have seen, 1024*1024px textures ...


2

The method camera.rotate() (and all other transformation methods on camera) act on the current state of the camera. So if it's rotated 30 degrees, it will add more 30 degrees to the rotation. If you want to keep at 30 degrees (but still applying the transform every step), you have to make it look back at whatever it was looking before. Assuming you're using ...


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


1

There's no need to use a framebuffer for this, as you're already using a Scene2D, which automatically does the proper scaling for you. You may be asking "LOL I've been using it all this time and haven't seen a single stretching!" It is easy, when you create your Stage, instead of instantiating it with stage = new Stage(new ScreenViewport()); do: stage ...


0

I use the same calculation and I don't have the same issue, perhaps the error is with the Gdx.input.getX(). I am not familiar with libgdx, so I can't comment directly on this. Maybe you can test this by shooting at an exact known location. One suggestion would be to color a pixel at say (300, 300), and shoot directly on it then check what the mouseX, and ...


0

I don't know how the Bullet class works, so I am just doing this from your code, but in your if statement: if (bullet1.collides(ball)) { // draws the bPop texture but the bullet does not go just keeps going around, and the bPop texture goes. batcher.draw(AssetLoader.bPop, 195, 273); } You are not actually removing the bullet which ...



Top 50 recent answers are included