Tag Info

New answers tagged

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.


0

Im using libgdx particle system for a snow effect here's the draft file ,this will need some tuning but a good start. In this effect the png get some light blue tint. You can simply import it ParticleEffect snowEffect = new ParticleEffect();<br> snowEffect.load(files.internal("snow_effect"), [files.internal("particle.png")][2]);<br> ...


0

If you mean by view the screen size / viewport , you could use the ScreenViewport function of libgdx.. ScreenViewport (LibGDX API)


0

I, you may have a look at Box2d light box2D light. The idea is to create shape in a box2D world and then use Box2D light to perform the shadow casting and light rendering. You then have to render the light on top of your scene.


0

Considering the example, I assume you mean a connected graph, i.e., there is a path from any point to any other point. First decide if you want it to be very sparse or if the graph might need be very dense (each type prefers a different data structure). Dense graphs are handled better by a 2D matrix of Booleans where position (j, i) is lit if j and i are ...


0

You want to create a list of nodes in an array and randomize the position values. You can then make a new array to store arcs. Make an Arc object with "Start Node, EndNode" and simply store random (Different) node numbers together for each arc you want.


0

The items spawned want to be objects with intrinsic position properties and a move method that can be called every frame or every set update to change the objects position downwards. As these are instantiated you can set up the y position such that they start just above the viable screen, and use a RandomNumber*screenwidth to determine the random x ...


1

Had a similar problem. Couldnt find anywhere the solution, only in libgdx irc channel. Huge thanks to jeffol on #libgdx @ freenode So to change text colors the text outputted from Hiero (i used BMFont) should be white. This is done in export settings - you need to set higher bit depth, and then you can tinker with r g b values. What worked for me was the ...


0

From LibGDX's docs: spriteBatch.draw(Texture texture, float x, float y, float width, float height, int srcX, int srcY, int srcWidth, int srcHeight, boolean flipX, boolean flipY) Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels. Set flipX as true to get your desired result


0

I think you need to figure out why this is happening. Can you reproduce the behavior by creating a daemon app and letting it run in the background? Do other games respond the same way exactly? If not then why is your game slowing down so dramatically is the question and it's a debug question. If you let the game continue as normal, it will probably highly ...


0

Of course if other apps are being installed while the user is playing your game it will lag. I don't think there's anything you can do about that since it is a function of the Android settings and not your game. Usually other apps do not take much processing power away from the current visible app. Maybe you personally have too many aggressive apps on your ...


1

LET THIS BE A CAUTIONARY TALE ABOUT BOX2D! Haha! Here's the solution I came up with The problem I amrunning into is due to the fact that Box2D uses meters instead of pixels for the scale, in my game a screen that is 1920x1080 would be 1920 meters wide and if I am using sprites a small sprite will be only as many meters wide as it is in pixels. The reason ...


0

I think you could switch your cos with sin and vise versa if you're really against adding 90 in your function, but I think adding 90 is a perfectly viable solution. Once a function works, you shouldn't have to care what's inside of it.


0

You don't. That defeats the purpose of a tween. A tween is supposed to control the speed itself using an easing function and giving it a total time. If you want to control the speed of an object, you'll have to give it a velocity yourself and update it through your normal game loop.


3

glClearColor expects color values to be in 0 .. 1 range, everything outside of this range gets clamped to it. In your case numbers are getting clamped to (1, 1, 0, 0) which is indeed yellow. Try setting glClearColor(60/255.0, 181/255.0, 0.0, 0.0); instead.


1

The distance moved does not take the delta time into account, so if you get updates coming at an irregular interval you'll get jerky motion. Scale your speed by the elapsed time, dt; public void update(float dt){ if(cont == true){ vec = makeVec(); x += vec.x * speed * dt; y += vec.y * speed * dt; } } This might mean you'll ...


0

For a very minimalistic car you won't need anything other than two values: velocity and direction. Both values can be just a floating point number. When steering left/right, adjust the direction, which could be as simple as being the angle the car is facing. Accelerating or breaking will modify the velocity. if (key_left) direction -= 0.001; else if ...


1

Dialog is better suited for modal pop-up windows, and it includes a "button" and "content" table already in the window (as the docs say). You can grab these tables with getButtonTable() or getContentTable(). The dialog makes it easy to work with pop up windows. For example, here is a confirmation dialog: Dialog diag = new Dialog("Warning", skin, "dialog") ...


0

According to libgdx's Box2D introduction, "The Box2D implementation in libgdx is a thin Java wrapper about the C++ engine", which would be in World.java in the libgdx sources, but it's not. So: No, there isn't. …yet! You could ask nicely in the libgdx issue tracker. (Or maybe implement it yourself and send a pull request if you know C++ Box2D? I'm ...


0

I solved it adding the ParticleEffect to he body and before rendering the effect in render function: public Body createThrowedBall(float x, float y) { Gdx.app.log("createThrowedBall", "("+x+","+y+")"); BodyDef ballDef = new BodyDef(); ballDef.type = BodyType.DynamicBody; ballDef.position.set(x,y); CircleShape shape = new ...


0

Right well, since no one has replied, I will post my solution. When adding Actors to the Stage, rather than doing: stage.add(actor); Which adds a Cell with the given Actor in it, I done the following: stage.addActor(actor); I was then free to overlap actors and move/scale/rotate them via tweening. The only probably I currently see with this is the ...


0

There's two things needed to solve this: Use a method called letterboxing. Build your game for one aspect ratio (16:9 works best for Android devices) and fill everything outside it with background image. Some developers just use black color, but background image is much nicer. Once you got that, find all the resolutions you want to support and draw ...


0

I figured it out, hope this helps someone someday :) Using the normal LibGDX approach, create a project using File -> Import -> Gradle (gradle build). Highlight all of the project folders and right click -> team -> share project Note: SVN does not support adding multiple folders at once, make sure to click 'Share Project' option. Enter repo URL: (I just ...


0

A thought. Have the player have their own world that's synched with the server world, then check for out of sync by using a special sync object with positional values (compare them every so often).


0

It's easy, you just need to set the width during the insertion of the items on your table. Example: dialog.getButtonTable().add(btnSound).width(900);


1

Imagine the radius is one. That means every point around the circle is exactly one unit away from the center. Now what kind of vectors always have a length of one? Unit vectors of course. You can get a unit vector by normalizing a non-unit vector. Take the vector CA (center to A). Next, normalize CA to make it a unit vector, then scale it by the radius of ...



Top 50 recent answers are included