libgdx

How to do blending in LibGDX

浪子不回头ぞ 提交于 2019-11-28 19:41:12
I basically want to play around with blending modes in LibGDX but don't know how to do it. I found this image on internet. I want to do the same thing on LibGDX. Can someone teach me how. I've been playing around using Scene2D. Here's my non-working snippet. private class MyGroup extends Group { Image red, blue; public MyGroup() { Texture texture = new Texture(Gdx.files.internal("images/red.png")); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); red = new Image(texture); texture = new Texture(Gdx.files.internal("images/blue.png")); texture.setFilter(TextureFilter.Linear,

Actions of Actors in libgdx

安稳与你 提交于 2019-11-28 16:53:23
I have made my Actor , but I am unclear on how to take advantage of the action and act methods. Outside of the basic Javadoc, I have not found a good tutorials on these methods. Can anyone provide an example with comments for actions on actors? Ludevik This answer is being rendered obsolete because of changes in LibGDX. For up to date documentation see scene2d wiki page . There are various available actions in LibGDX ready for you. They are in com.badlogic.gdx.scenes.scene2d.actions package. I would say that there are 3 kinds of actions: Animation actions Composite actions Other actions

TrueType Fonts in libGDX

爷,独闯天下 提交于 2019-11-28 15:59:24
Does anyone know how I can use a TTF font in libGDX? I have looked around and have seen things about StbTrueTypeFont but it doesn't seem to be in the latest release. EDIT: I found the StbTrueType font stuff, the jar file is located in the extensions directory. I've added it to my project. Now I just need to figure out how to use it. Any examples? Yes you will definitely need to add the gdx-stb-truetype jars to your project as you stated in your edit. Here is how you will use it, pretty straighforward... First you need to declare your BitmapFont and the characters you will use... BitmapFont

How Camera works in Libgdx and together with Viewport

好久不见. 提交于 2019-11-28 14:47:09
If you work with LibGdx it goes not long until you come to Camera and viewport. If you work the first time with camera and Viewport you get some questions about how it works and how to use it. So: How can I use a Camera in LibGdx? What's viewport width and height? What is a Viewport, how can I use it and how it works together with the Camera? How can I use a Camera in LibGdx? What's viewport width and height? Firstly it's important that you know the Camera works with World units not with Pixels. World units are not a regular Unit. You self can define how much one World Unit is. Later more.

LibGdx-ViewPort width and height does not match for some devices

你离开我真会死。 提交于 2019-11-28 14:34:38
I am using a Viewport for my libGdx landscape game like this. public static final int WORLD_WIDTH = 1280; public static final int WORLD_HEIGHT = 800; camera = new OrthographicCamera(); float aspectRatio = Constants.WORLD_WIDTH / Constants.WORLD_HEIGHT; ViewPort viewPort = new FillViewport(WORLD_WIDTH * aspectRatio,WORLD_HEIGHT, camera); I am using all positions in terms of this width and height. It is working fine in all devices except device that have screen resolution greater than 1300. In device that have greater resolution than 1300,only middle part of the game is visible.I tried using

Libgdx's World Units

天大地大妈咪最大 提交于 2019-11-28 14:19:45
I've been trying to learn libgdx a little but now i'm kinda confused about world units there that i don't even know what exact question i should be asking. Anyway, i've been reading this example game code here and from what i understand, when there's no camera, SpriteBatch renders everything in relation to device resolution, so pixels, but when we make a camera, set it's "size", position and then use batch.setProjectionMatrix(camera.combined) , batch translates pixels to units and then it knows where to render , but in this game there's collision detection between Rectangle objects, and when

libgdx ScissorStack not working as expected

不想你离开。 提交于 2019-11-28 14:00:46
I'm trying to create a "progress bar" of sorts but the clipping doesn't seem to work the way I expect it to. Is this something I am doing wrong or something I've misinterpreted? The draw() routine that should clip: @Override public void draw(SpriteBatch batch, float parentAlpha) { Rectangle scissors = new Rectangle(); Rectangle clipBounds = new Rectangle(getX(), getY(), getWidth() * 0.75f, getHeight()); ScissorStack.calculateScissors( getStage().getCamera(), getStage().getGutterWidth(), getStage().getGutterHeight(), getStage().getCamera().viewportWidth, getStage().getCamera().viewportHeight,

Is there an upper limit on velocity when using box2d?

断了今生、忘了曾经 提交于 2019-11-28 13:23:51
I'm using box2d for physics simulation. I'm moving a circle using arrow keys by applying impulse on the body when ever a key is pressed. Unfortunately, the circle moves excruciatingly slow and doesn't seem to accelerate like a true physical body is supposed to. My world's dimensions are 400x800 pixels. The radius of the circle body is 20f. According to this , the problem can be solved by scaling the circle radius down when creating it and scaling up after getting the body position during painting. It doesn't seem to make any difference at all. Is there some step or setting I'm missing here ?

Add Actions.scaleTo() to a Label in LibGDX

不羁的心 提交于 2019-11-28 13:00:58
In LibGDX, I want to make a text animation for my game. Therefore, I want that my labels gets larger with time. But if I use the scaleTo() method, nothing happens whereas other Actions like moveTo() work fine. label1 = new Label("Test text", new Label.LabelStyle(font, Color.BLACK)); label2.addAction(Actions.parallel(Actions.moveTo(500, 300, 2.0f),Actions.scaleTo(0.1f, 0.1f,2.0f))); label2 = new Label("Test text 2", new Label.LabelStyle(font, Color.BLACK)); label2.addAction(Actions.parallel(Actions.moveTo(500, 300, 2.0f),Actions.scaleTo(0.1f, 0.1f,2.0f))); stage.addActor(label1); stage.addActor

LibGdx resolutionFileResolver + Assetmanager, file names?

自作多情 提交于 2019-11-28 12:57:28
I want to use the resolution file resolver to select a correct texture atlas for my app, so I createa RFR with a couple of resolutions: Resolution _568x1136 = new Resolution(568, 1136, ".568x1136"); Resolution _1200x1920 = new Resolution(568, 1136, ".1200x1920"); ResolutionFileResolver resolver = new ResolutionFileResolver(new InternalFileHandleResolver(), _568x1136, _1200x1920); manager = new AssetManager(); manager.setLoader(TextureAtlas.class, new TextureAtlasLoader(resolver)); Now I'm wondering, how do I name/place the files?????? I tried adding .1200x1920 and .568x1136 behind BOTH the