Tag Info

New answers tagged

0

Yes the solution is you get value from your matrix or array and set That value for temp array or matrix and Then set value from there this is show you your rotate value gird. I added code below i think its help you int MAX_GRID = 4; int[][] main_array = new int[MAX_GRID][MAX_GRID]; int[][] temp_array = new int[MAX_GRID][MAX_GRID]; /** ...


0

Try not to think in screen position, but world position. Place the emitter above the camera position with some offset each frame and spawn particles from there.


0

It has now been pointed out to me that on this page it says Note: If you're replacing a "regular" font by a distance field font, be aware that the font metrics are not the same. In particular, the extra padding causes the baseline to shift downwards, so you'll need to compensate by drawing your text higher. So this is a known problem using the libgdx ...


3

The problem is you need to close the loop, to make sure the lasso is complete (based on the behavior of the video). You do that by testing if one of the segments intersect with another segment, thus closing the loop. It might look something like this (note I don't use libgdx, so this is untested): Array<Vector2> path = p.getPath(); // Look for an ...


0

If performance isnt a problem for you and you want simple solution, just draw a thick line and check color under your cursor. If at any point the color was equal to the line color, you know the polygon was closed. This can be even improved by checking color of all pixels between last and current mouse position. Other option would be to perform MANY line ...


0

This needs to be done when you create the Box2DLight's Light object. You can fix this by setting the setSoftnessLength(float) on the Light object. For example: m_Light = new ConeLight(...); m_Light.setSoftnessLength(1.5f);


0

An animation is just a group of frames which are drawn sequentially. If you were able to render one animation, to change it you just have to change the frames. That example splits a Texture into TextureRegions by splitting it in a grid, I recomment you create a TextureAtlas instead, its easier to access the different TextureRegions in it. To change the ...


0

I've been facing a similar problem recently and all was a matter of 'world' units vs pixel units. Which units are you using for the camera and/or viewport? In case you defined such dimensions with 'world' units you should draw your back TextureRegion specifing the corresponding size in 'world' units. backgroundMapRenderer.getSpriteBatch().draw(back, 0, 0, ...


1

Short answer: by smart compositing rotation and translation. In the image below you can see the process (radius r is distance of your planet from star). If you rotate the moon by rot_m degrees(updated in main loop), it will circle the origin point. If you first rotate and then translate by radius r it will circle in right distance but wont follow your ...


0

Polygon A is overlapping polygon B if any of its vertices is inside B and vice versa. bool isOverlap(Polygon A, Polygon B){ foreach(Vertex v in A) { if(isInside(v, B)) return true; } foreach(Vertex v in B) { if(isInside(v, A )) return true; } return false } bool isInside(Vertex v, Polygon p) { //you can choose either ...


0

I found the solution and now it works: import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.TextureRegion; public class BitmapFontShader extends BitmapFont { private final Texture.TextureFilter ...


5

I assume this is because in these cases the grid lines are not exactly on screen pixels, but somewhere in between. Is this correct? Yes, this is correct. The camera in LibGDX is based on a vector, which is made out of floats. When your camera is in between pixels (like at (1.2f, 63.5f)), then you will start to see that blur you mention because the ...


2

Sure, why wouldn't it? As stated on BadLogicGaming's Official Website: The license basically states you can do with the source whatever you want, copy it, modify it, include it in open and closed source projects without getting infected by the license itself. You can do whatever you want with what you made. Just make sure you comply to these 3 lines if ...


0

This is a well-known feature of libGDX: the Y-axis has 0 at the bottom of the screen, not the top. (This is to be more consistent with 3D coordinate systems, which do likewise.) There are a couple of ways to "fix" this. Use a camera. You can transform the view. In your render method, calculate the Y position as screen.height - y - sprite.height. This is ...


0

Unless you know of a third-party service for leader boards that can be used on all devices, you'll have to write platform specific code. The wiki has a tutorial on that.


1

Definitely not. Table is just a tool and you should use it when it fits your desired result. If your widgets are supposed to be laid out in a tabular way, then use Table. Otherwise, it's perfectly okay to position your widgets manually if that's what you need. Two alternatives to Table HorizontalGroup: Just one example of a component made specifically ...


0

(Most) Android devices' input are from the touch screen. If that is your case, and you are trying to fetch touch events, you have two options: 1 - Poll every frame if the LEFT key is pressed. Basicly, instead of your Gdx.input.isKeyPressed(Input.Keys.LEFT) what you want to check is: Gdx.input.isButtonPressed(Input.Buttons.LEFT) From javadoc: ...


1

I'm assuming that you may be doing setTransform() on PBox to move the player around based on mouse positions. If that's the case, it is bound to happen, since setTransform occurs outside of the physics calculations. Consider adding a Joint to drag the pBox around (with large force).


0

Theoretically, sure. Two approaches come to mind: Write a shader Fake it For faking it, you could draw four copies of the sprite (offsetting horizontally and vertically by 1px above/below/right/left of the main image) and tinting that to your neon colour. I haven't tried it, so your mileage may vary.


1

A simpler way, that will also speed up your program, is to check if your circle is moving towardas the other circle before check for a possible collision. You can do in it in this way: vector2 p; p.x = other.position.x - your.position.x; p.y = other.position.y - your.position.y; if(p.x*yourSpeed.x + p.y*yourSpeed.y > 0 { //check for collision; } look ...


0

Having a list of textures in an array is not a great idea. What if you decide to put them into a texture atlas later (which is generally more efficient than loading a bunch of files)? What if you change the order of a file in the middle? You'll have to re-order a bunch of your data. A more flexible approach would be to keep not just a flat file name or ...


2

Your problem is that you are checking for a collision and then stopping, this means that if your frame places you to far into an object you are now stuck. To solve this you have to solve the equation of exactly where both object were when they hit one another. So you have to find where the following is true: |t*v1+p1-t*v2+p2)|=|r| where t is time v is ...


1

You can initialize tile1, tile2 and tile3 and then you can add them to Array. tile1 = new Texture(Gdx.files.internal("grass.png")); tile2 = new Texture(Gdx.files.internal("dirttile.png")); tile3 = new Texture(Gdx.files.internal("watertile.png")); Here is how you will initialize Array: Texture[] tile = {tile1, tile2, tile3};


0

libgdx is under the apache 2.0 license meaning that you can use it freely in both for-profit, non-profit,open-source and closed source games. Selling a game on steam makes it for-profit and likely closed source so you will be fine as long as you read at least once through the apache 2.0 lisence (it's not that long).


0

No, there's no technical or legal issue why you can't sell your LibGDX game on Steam. However -- and this is not specific to any platform or library -- your game needs to be pretty good for it to get their attention.


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


3

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



Top 50 recent answers are included