Tag Info

Hot answers tagged

4

You should consider using a plain 2d-array or alternatively an array of rooms, where each room is a 2d-array or a grid. A grid would looks something like this: The player is the yellow dot and the blocks are the green ones. if the player is the light gray square, you only need to check for blocks that around that square area. This saves you the time of ...


4

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


3

This game is a good example why you can't always automatically port a game from one platform to another. Having the player-character follow the mouse cursor works well when the user has a mouse, but most Android devices have no mouse, so a different input method needs to be used. In this game, the gameplay is tightly connected to the input method. This means ...


2

The scheduleTask function's source suggests that it expects the input in terms of seconds instead of milliseconds. public void scheduleTask (Task task, float delaySeconds, float intervalSeconds, int repeatCount) { if (task.repeatCount != CANCELLED) throw new IllegalArgumentException("The same task may not be scheduled twice."); ...


2

It depends how you want to do it. libGDX "recently" moved to Gradle, which, among other things, manages dependencies for you. Your options: Do it the Gradle Way Open up build.gradle for both projects add the right dependency under dependencies You find the exact string, you need to use Maven Search, then click on the version number, then click on ...


2

Change your thought process from "Moving 7 units" to "Applying a velocity of 7 units" and you can come up with something like: velocity.Y = -7; position.Y += velocity.Y; Now if we take this and we want to apply acceleration every frame we can simply update the velocity every frame. accelerationRate = 2; //arbitrarily picked - no significance velocity.Y = ...


2

I found this in the libGDX source code, in class Sprite.java public void draw (Batch batch) { batch.draw(texture, getVertices(), 0, SPRITE_SIZE); } So no, no difference. It shows Sprite.draw is only syntactic sugar for the longer version you posted.


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


1

Swapping the width and height in ShapeRenderer.rect should fix the problem, see the documentation.


1

Ashes999 is right there but I took some extra steps in order for it to work so here they are: 1) Create a libs folder inside the core project's root folder and add whatever JARs you got inside it. 2) In the build.gradle file which is inside the main root folder that contains the various platform projects find where it declares the dependencies of the core ...


1

Don,t do any thing just set the scale of the font and it will work for all type of device font.setScale( .9f,.9f);


1

You should use BitmapFont.drawWrapped. public BitmapFont.TextBounds drawWrapped(Batch batch, java.lang.CharSequence str, float x, float y, float wrapWidth) All you need to do is set the wrapWidth variable as ...


1

position.y -= 7f; change 7f to a variable var fallspeed = 7.0f; position.y -= fallspeed; increase the fallspeed every update var fallspeed = 7.0f; var gravity = 5.0f; position.y -= fallspeed; fallspeed += gravity; This creates a linear acceleration. Gravity on the other hand isnt linear, so you might wanna try something like this var fallspeed = ...


1

Another option would be to spawn a fixed number of snow particles and make them teleport to the top when they reach the bottom of the screen. This is trivial but in your case it should work fine.


1

Your IDE of choice should have a way for you to navigate to the source for a specified class. For IntelliJ IDEA try moving your cursor to the Game class name that MyGdxGame extends and pressing CTRL + B. That should take you to the source for Game. Take a look at the override for render() that Game implements. @Override public void render () { if ...


1

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.


1

When you call effect.setPosition(...), it changes the position of all the emitters, but not of the particles. In libGDX, there is currently no way of changing the position of a single particle, so in order to draw particles at 2 locations, you must do the following: // Pseudo-code move effect at position 1 add particles move effect at position 2 add ...


1

I have no idea about how JSON of the libGDX parser works, but from what I can see, only keys with a value of 0 were removed. So in your code, if you cannot read the value from the JSON, put 0 as the default one. Also, you can play with the JSON parser to have a better print if you want: http://stackoverflow.com/questions/23401431/libgdx-json-parsing


1

You can use this: ((Sprite)body.getUserData()).getHeight(); it should answer your question if I guessed your problem correctly.


1

For your collision I would merge adjacent colliding tiles together into one big collision box instead of iterating over every single tile and checking their individual collision. Also I think that a quadtree would work much better than your current approach with a HashMap as it splits your gameworld up in sections and make it easy to delete a section of ...


1

You are correct that libGDX doesn't contain any sort of built-in support for rendering sprites in a certain order. (If it's there, I haven't seen it, and I've been using libGDX for a number of years.) What I do is create a SpriteComponent class that wraps the Texture object and emits x, y, and z attributes. Then in my draw method, I sort all ...


1

Without being able to modify the position of the individual particles, I don't think you're going to be able to achieve what you're looking for. Take a look at a live wallpaper that I made, source available here. What I do here is I track each particle individually, and I can move them according to the rules set by the appropriate system. If a particle hits ...


1

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



Only top voted, non community-wiki answers of a minimum length are eligible