Tag Info

New answers tagged

0

Use ShapeRenderer http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html. Note that it's pretty slow and you'd better just use triangle sprite for that.


1

Here is an official Spine 2D example where they load Spineboy into a game. https://github.com/EsotericSoftware/spine-superspineboy The following 3 lines are used to read a texture atlas and skeleton data as well as making some animation state data. TextureAtlas playerAtlas = new TextureAtlas(Gdx.files.internal("spineboy/spineboy.atlas")); SkeletonJson ...


0

Think about having only one final Tile class and it defines only the data needed to render and update like the id of the Sprite or TextureRegion public class Tile { private int type; private int spriteId; some other data that you need and that belongs to a Tile ... public int getType() { return type; } public int ...


0

You can use an anti aliasing algorithm to fix it. One simple way to do AA is to take multiple samples per destination pixel when you down sample. Here's a link to one such method, called 4-rook ssaa! http://blog.demofox.org/2015/04/23/4-rook-antialiasing-rgss/


0

@Override public void create() { gameScreen = new gameScreen(this); setScreen(gamaeScreen); } Is the setScreen(gamaeScreen) a typo (gamaeScreen) ???


0

Having all Tiles be Actors that draw their sprite in the Actor's draw() call is an option. Of course there are many ways to draw a map, but this definitely is one of them. However I would warn against using Sprites. Since you said all tiles are 16x16px you will likely have very many of them in each level of your game. This would mean that you would have ...


2

The constructor of your gameScreen class does not initialize the camera and renderer fields, what you're initializing in the show method are method-local variables with the same names. That's why they're null when you're in the render method. Try changing OrthogonalTiledMapRenderer renderer = new OrthogonalTiledMapRenderer(map,unitScale); ...


0

Since you are using Actors you can simply give the actor an Action. For scaling you could use this method: myActor.addAction(Actions.scaleTo(scaleX, scaleY, duration); Then when the user stops pressing the button you can cancel the current action and give the actor a new one that scales back down to the original size.


0

To make this work you need the two stages to communicate. There are two ways you could have the result you desire. Have each actor you create (that is touchable) contain a reference to the HUD stage. Then when the actor is touched, simply update the HUD by calling a method with the actor as a parameter (hudStage.update(thisActor)). Do not assign listeners ...


1

When you "enter full-screen", the base window's border is removed and it is re-sized and moved such that its' ClientBounds == ScreenBounds. When this occurs, the Device is destroyed ("lost"), and needs to be recreated. At the same time, the back-buffer and any other textures or rendertargets that should be "full-screen" must also be re-created with the new ...


5

What's happening First of all, note that this behavior is not specific to oblique collisions. Below is an example of two balls colliding head on with a wall. All fixtures have m_restitution = 1.0, and m_friction = 0.0. The ball on the left is traveling with v = 0,1 and the ball on the right has v = 0,1.01. I found three similar questions asked on the ...


0

I am not familiar with libgdx, so I apologize if this might be a bit out of place; but don't you need a script for the wall class? Right now it seems the wall is simply acting like it should react and do nothing to affect the ball's movement, so the ball will continue going in the same direction on the black arrow. Make it such as that if the wall is hit, ...


2

The position of a Box2D body is defined as its center. So if you set the body's position to the lower left corner of the Sprite, then it will be displayed as you showed in the image. What you need to do is set the Body's position to the center of the Sprite like so: bodyDef1.position.set(player.getX() + player.getWidth() / 2, player.getY() + ...


0

You could try picking out the angle property of your emitter (or emitters if you have many) and manually adjust the values to center around some angle. ParticleEffect effect = /* your effect */ ParticleEmitter emitter = effect.findEmitter("some_name"); // find the emitter you want to rotate here float targetAngle = /* your target angle */ ...


0

What you are currently referring to as FRUSTUM_WIDTH, FRUSTUM_HEIGHT is actually the world width and height for the camera. This means that, across your application window, 8 world units in width and 12 world units in height will be displayed. Since you are not changing the size of your Sprite, it will have the texture's width and height, so it will be ...


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


0

Same issue. It seems to be due to when the batch is flushed? Anyways basically every Actor sibling seems to also fade with it. Also will happen with any setColor as you might expect. Workaround I have done is just wrap it with a group. Update: Actually last item in group seems to always have issue, even if wrapped. Need a flush? Or whatever resets the ...


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

I will assume you are using a DragListener or something similar to achieve the "panning" effect. This is the method I have that keeps the camera within its bounds: private void keepCameraInBounds () { Camera c = this.getCamera(); Vector3 camPos = c.position; float HW = c.viewportWidth / 2, HH = c.viewportHeight / 2; camPos.x ...


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


0

The answer I gave in the other question doesn't quite do exactly what you want, but the following example might help. You still need to re-proportion both the heights to do what you want, but you also need to move the input data region down to compensate for the smaller window: spriteBatch.draw( sprite.getTexture(), x, y, width / 2, ...


0

It's quite possible to partially draw a sprite using the SpriteBatch.draw(Texture,...) rather than the SpriteBatch.draw(TextureRegion,...). As long as you only intend to draw a rectangular sub-section of that sprite. Note, Sprite is a TextureRegion. If you have a Sprite that you are already drawing, you can get the Texture itself from the Sprite using the ...


0

If you are working solely with Sprites I do not believe there is a good way of drawing part of a Sprite. If you want to keep working only with Sprites I would recommend splitting the original Texture beforehand and creating a separate Sprite for each piece. However, if you could work with Textures (i.e. you do not need to rotate the partial Sprite) then you ...


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


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


0

Setting the glClearColor, as Josh Petrie said, is only necessary to do every frame if you do not know if another part of your program is changing it. Although, usually you would be drawing your own background, which would cover the entire background, so the color should not matter. (Of course, you still need to clear the screen every frame to prevent ...


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


0

Edit: As usual, I've not paid attention and answered a GL question with DirectX code; sorry... Although the API differs, the idea is very much the same. It will technically qualify as a performance loss, but it may be unavoidable. Ideally, you only want to notify the video card of changes to "whatever is current". Since you are in complete control of the ...


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


0

There are overloads for Texture() that allow you to pass a Pixmap.Format. The list of formats is quite limited. Per OP: texture = new Texture (Gdx.files.internal ("gs.png"), Pixmap.Format.LuminanceAlpha, true);


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


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.


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


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



Top 50 recent answers are included