Tag Info

Hot answers tagged

4

Alpha mask texture approach In case your circle would always be the same size, using a second alpha mask texture would be the way to go. You would make it a grayscale mask texture and use its value as the alpha value while drawing. Using a texture had the benefit of having anti-aliasing built into the mask (ie. at the borders of your circle, the pixels can ...


4

The artifacts are caused by scaling the images using point sampling / nearest neighbourhood filtering, which effetively doubles some of the pixels from the original image. To get better results, switch to bilinear filtering which uses weighed average of multiple pixels. The result will be a little blurry, but should look a lot better than the current one. ...


2

The GestureListener is something that should be passed to a detector, and the detector (which is an InputListener) will read touch events and amalgamate them into higher order events such as pan, fling or long press. So I would expect your code to have something like this somewhere; Gdx.input.setInputProcessor(new GestureDetector(new FlingHandler())); ...


2

You could have an array of coordinates of collected coins, and then iterate over that and restore them when the level should be restarted. In general, for this problem you will want to keep the information around that you will still need later. You can do this either by remembering specific things explicitly or by cloning the original data.


2

You have to return true from touchDown. Documentation says: The GestureListener can signal whether it consumed the event or wants it to be passed on to the next InputProcessor by returning either true or false respectively from its methods. So, if you return false from touchDown, that is the first even raised in all cases, it stops event handling. If ...


2

This is due to either a context loss or simply you disposing your textures, without recreating them at the proper time (as you pointed out).


1

//At the apex of the jump, Ruben's velocity.y is ~0 if (Math.abs(ruben.velocity.y) < 1) //If Ruben's velocity.y gets close to 0... { ruben.velocity.y = 0; //stop him Ruben.setState(Ruben.RUBEN_STATE_IDLE); } //velocity.y = +1 //jumping //velocity.y = 0 //no more jump left; begin falling (except the if activates) //velocity.y = -1 //falling Edit - ...


1

The most likely problem is that in one of your actor's draw calls you are forgetting to reset the batch's color. This would cause alpha transparency to carry throughout your entire stage. Make sure you always reset the batch's color at the end of a draw call where you manipulate it. Here is an example: public void draw (Batch batch, float parentAlpha) { ...


1

Use Array (or regular java [] array!) (Ground[] grounds = initialize all;) with index that points to the first visible Ground in that array (int first = 0;). Keep some counter (float x = 0;) which will hold progress to the next index. void update(float delta) { x += delta * speed; if(x > groundWidth){ x -= groundWidth; ...


1

In Bob's update method you do nothing with his velocity. He has no way of actually moving, with the code you have shown. You should do something along the lines of this before you reset the bounds: position.add(velocity.x * deltaTime, velocity.y * deltaTime);


1

In LibGDX Doc Gdx.gl.glClearColor(0, 0, 0, 1); and batch.setProjectionMatrix(camera.combined); is setting in render() method at a time. I use this definitions in create() method at once, and it is running perfect. So why should i use this definitions in render() method? is't it a performance loss? The clear color is part of your OpenGL ...


1

You can create a Cell and fill that with a tile from the TileMapTileSet, then set that cell at (x, y) coordinates in a particular Layer. For example, the following code sets the tile at (32, 64) in a layer to tile 42 from tile set tileset_name; TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().get("some_layer_name"); Cell cell = new Cell(); ...


1

I had a look at the ScrollPane source code on GitHub. That's quite a difficult problem. The animation is done in the ScrollPane's act method. If you set the scroll value manually, the visual scroll value used for rendering will align on the scroll value over time through an interpolation process (usually in a few frame). Here is the code responsible for ...


1

You could try creating your own version of the ScrollPane by inheriting from ScrollPane and then overriding visualScrollX(float pixelsX) and visualScrollY(float pixelsY), and multiply the parameter by some factor before calling the base class implementation; class MyScrollPane extends ScrollPane { @Override protected void visualScrollX(float pixelsX) { ...


1

The best solution is to re-create project with libGDX setup tool and copy all source code and asses into it from old project. .project file is file that contains information about project Eclipse should know. Do you use Gradle? If so, do you import project into Eclipse as Gradle Project (right) or as Eclipse Project (wrong)? And it's pretty bad idea to use ...


1

I think easiest way to solve this is to use very simple maze solver tactic. That is the "wall follower". Find wall Put your hand on the wall, either left or right of you Keep hand on wall Start moving Never let go off the wall, if there is a turn, you turn with the wall and if its "dead end" you turn but you still keep your same hand on the same side ( ...


1

This may help a bit. As for knowing how to do what you exactly want to do, I would need hours of trial and error as I am also a bit of a beginner. public void create() { gestureDetector = new GestureDetector(HALF_TAP_SQUARE_SIZE, TAP_COUNT_INTERVAL, LONG_PRESS_DURATION, MAX_FLING_DELAY, new GestureHandler()); ...


1

A nice way to implement what you are trying to achieve would be to use a SequenceAction and built in libgdx actions : tooltip.addAction(Actions.sequence( Actions.show(), Actions.fadeIn(1f), Actions.delay(4.5f), Actions.fadeOut(1f), Actions.hide()) ) Actions.show() basically call setVisible(true) on your actor and Action.hide() call ...


1

Like Khopa has stated, use Android Studio. I still a beginner bit of a beginner to libgdx, but so for I have found that Android Studio covers all of my needs. You can even run the desktop version from A.S. and on the plus side, you can easily emulate an android device using the built in intel HAXM, only works with intel cpu's. For AMD use genymotion, which ...


1

As workaround, I personnaly use Android Studio which is based on Intellij Idea when developping LibGdx app for Android. Just import build.gradle in Android Studio, and you should be ready to edit your core, desktop and Android libGDX project without any further configuration.


1

Are all coins doing the same animation? You could make a method in the Animation class that takes a coin as an argument, then performs the animation on that coin. Then, on another class, you make a loop that traverses the coin list and calls the method in your Animation class, therefore animating each coin as you go through the list. You can also add delay ...



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