Tag Info

New answers tagged

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


1

Input.setCursorImage() will do that for you. Something like this: Pixmap pm = new Pixmap(Gdx.files.internal("cursorImage.png")); Gdx.input.setCursorImage(pm, 0, 0); pm.dispose(); The hotspot parameters represent the "tip" of the cursor. For example, the operating system cursor has the hotspot at the top-left corner, but a crosshair cursor might have the ...


0

It seems that you set up a Camera and a Viewport but are not using them. On resize() of the MyGdxGame class, the camera should be updated also: public void resize(int width, int height) { viewport.update(width, height); camera.update(); } Then, this should be inside your render(float delta) method before the batch.begin(): ...


2

All of the atlas regions are automatically available through the skin as TextureRegions. I just tried it, and works without modifying the json file. You can just call skin.get(name, TextureRegion.class); or skin.getRegion(name); Unfortunately, the skin docs are not very clear about this. libGdx docs


0

Well, just a simple way to do it, in your player class create the 3 textures for each animation if you're not using a TextureAtlas, then use a int playerState to specify the state of the player (1 for running, 2 for jump, 3 rolling down),and finally in the draw method use a bool to check playerState and draw each animation.


0

The 'Tiled Map Editor' sets the size (width and height) of map objects by default to 0. For most objects this is not relevant (polylines, rectangles and triangles which are handled as polygon objects) since the vertices are important. But for circles and ellipses I had to set a real value of course.



Top 50 recent answers are included