Tag Info

New answers tagged

1

dNot sure if a more specific answer is needed here, but for me to fix this issue I had to adjust the projection matrix on the SpriteBatch. Although destroying the SpriteBatch and recreating it would also work. So in my constructor I create the camera: camera = new OrthographicCamera(); Then when the size of the window changes I execute: ...


0

Found the answer, instead of the static Table.drawDebug(stage); call there is an instance method called stage.setDebug().


0

In the inner for loop, shouldn't you be incrementing k instead of i? You're doing i++ twice, so at some point, your code is trying to access Main.currentBullets.get(10), which is causing your Index 10, size 10 to get thrown.


0

Like you said, you need a scaling factor. float scaling = // some number. Probably something like 100 will do for Box2D. public Vector2 metersToPixels(float xMeters, float yMeters) { return new Vector2(xMeters / scaling, yMeters / scaling); } public Vector2 pixelsToMeters(float xPixels, float yPixels) { return new Vector2(xPixels * scaling, ...


0

The easiest solution I found was to attach a sensor with a radius the sum of the two radii to the second circle and a RayCast callback returning the fraction and filter for just sensors. The collision point is where the center of the first circle will be upon contact. a vector between the contact point and the center of circle two gave me the predicted path ...


0

The bounding box automatically move with the sprite. If you don't believe it, use the ShapeRenderer to draw your sprite's bounding box each frame and check if it actually follow it or not.


0

Oops! redfaced I made a typo in the name of the file I trying to open. In my assets/data folder the file was named tile.png not title.png. Thanks to Justin-C on #libgdx irc


1

Can't speak to the exact implementation details (and if I could it would be off-topic), but here's some obvious ingredients to put together: The camera is using an orthographic projection. You can tell this because a vertical wall is exactly vertical on-screen no matter where it is — if the camera were perspective then they would be "leaning outward" from ...


0

I don't how you want to implement what I gonna say, but in most 2d game engines we have something called TouchListener (or in general term EventListener) which can assigned to your card sprite (and many things else) and tell how should your game card handle touches. I can bring you a piece of code which is for a Game Card that I wrote in cocos2d-x engine. ...


2

This is an old question, so I'm guessing that tom37 may have moved on by now, but I think I have an answer for anyone else with the same problem. For reference, here is a view of a surface grid using a perspective camera. Now let's say that we want to render a portion of this current view, but to the entire screen. Let's render the top-left quarter of ...


1

If you have read access to the audio wave, there are a few ways to do it. I will cover an accurate, and a fast method. If you do not have read access to the audio wave, you need to get access to the audio wave. I'm not familiar with libGDX, but I highly doubt it has built-in functionality for this. It's not functionality that is typically needed, or asked ...


2

Not sure if this is the best way for detecting gestures, but this is how I would do it: On touchDown() I would set two member variables to store where the touch began. int xStart; int yStart; int xDrag; int yDrag; boolean gestureStarted = false; public boolean touchDown(int screenX, int screenY, int pointer) { xStart = screenX; yStart = screenY; ...


0

Give the ball some restitution (box2d property) having a rigid circle body attached, and later, simply apply some force to it ;) It will work as shown (of course, u should be having some bounding box) Could give you currect code if u needed :) code: Body ball; BodyDef _b = new BodyDef(); _b.position.set(new Vector2(0, 0)); //your wish _b.type = ...


0

You are most likely using compressed images on disk, when you try to access the data like images or audio files, the library is most likely decompressing them. One way to reduce memory is to use compressed texture formats. I don't know about libgdx but this is the way to go to reduce memory usage for textures. Regarding audio files, you can use lower ...


0

You can use this library github.com/pents90/svg-android only for android. Andengine (IDK if still in development) has an extension using this library https://github.com/nicolasgramlich/AndEngineSVGTextureRegionExtension LibGDX is not integrating this kind of feature because cannot support all platforms, just android, you can integrate this manually if your ...


0

I don't know if this is going to work, but if I was you, I would only use one chunk at a time and that is the number of tiles that are visible. So something like 32x32 chunk should be fine, it depends on your viewPort and tile seizes. That way the performance should be much better.


1

I think you need to find the needed ratio between Texture size and meters. I would probably use 100px:1m. Then, when you are setting the fixture sizes, multiply the texture size with the ratio. Try something like this: //RATIO private float ratio = 1/100; // TEXTURE private Texture texture = new Texture(YOUR TEXTURE PATH); private float fixtureHeight = ...


10

The PNG files are small because they are compressed. When the images are loaded into memory they are uncompressed and therefore take up more space.


0

I think your code looks just fine, but the only thing that bothers me, is that you use the batch from Game class. I think you should use new SpriteBatch for each new Screen and not using the one from Game class. Or change your structure of code and have Game class which calls render function from LibGDX and from that render function call render functions ...


1

You are loading textures and models from files on disk, that's your problem. File I/O is very expensive and should be avoided as much as possible. Preload your model and whenever you need to add a badger, clone one from the preloaded and just alter the properties that you need to.


0

Given an angle you wish to rotate to angleTo, and the current angle angle, you can apply an easing function to angle as follows (assuming all angles are in degrees): // see http://stackoverflow.com/a/7869457/1446919 double angleDifference = (angleTo - angle + 180) % (360) - 180; double ease = 0.1; angle += angleDifference * ease; // Ensures angle reaches ...


1

You have a translate function outside of the if statement. . . . if(!turn){ bug.translate(v.x * Gdx.graphics.getDeltaTime(), v.y * Gdx.graphics.getDeltaTime()); } else{ bug.translate(-(v.x * Gdx.graphics.getDeltaTime()), -(v.y * Gdx.graphics.getDeltaTime())); } bug.draw(spriteBatch); ...



Top 50 recent answers are included