libgdx

How to use Bitmap font as scene 2d actor?

流过昼夜 提交于 2019-12-03 21:59:49
I am developing a game using libgdx framework. How can i achieve scene2d action on bitmap font object ? so that i can write some text like score,message and run action like scene2d actor. Take a look at the Label class, particularly the constructor that takes a CharSequence and a LabelStyle . When you initialize your LabelStyle you can supply a BitmapFont. Please note, if you'd like to scale or rotate the label you'll need to wrap it in a Container or add it to Table with setTransform() enabled. (This flushes the SpriteBatch so use it wisely.) you can extend actor class to achieve the same.

rewarded video ad example in libGDX

你说的曾经没有我的故事 提交于 2019-12-03 21:56:00
I've been looking for an example, but didn't found it. I found one without libgdx and some why it didn't work, but app also didn't crash. public class AndroidLauncher extends AndroidApplication implements AdHandler, RewardedVideoAdListener{ ... RewardedVideoAd rewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this); rewardedVideoAd.setRewardedVideoAdListener(this); rewardedSetup(); private void rewardedSetup(){ if (!rewardedVideoAd.isLoaded()){ rewardedVideoAd.loadAd("ca-app-pub-683510441556959xxxxxxxxx", new AdRequest.Builder().build()); } @Override public void onRewardedVideoAdLoaded()

Libgdx rotate ModelInstance

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 21:31:09
I am developing my first libgdx 3D game. Until now i can move arround in a maze-like (hardcoded) world, collision detection works. Also i have some enemies with working A* Pathfinding. I also loded my first (pretty ugly) Blender model, using FBX-Conv to get a .g3db file. For some reason the model lise on the floor instead of standing. Maybe i had some wrong settings when i exported it as .fbx . For that i tryed to rotate() him arround the z-Axis by 90 degrees by calling: modelInstance.transform.rotate(Vector3.Z, 90) in the show() method of my Screen , after loading the Model and instantiating

How to get the phone language with libgdx?

倖福魔咒の 提交于 2019-12-03 20:23:51
I'm tyring to set a default language for my game and I would like it to be the phone's language, the question is: how can I get the phone's language? In my last game I used the default locale of the JVM: java.util.Locale.getDefault().toString(); to get the device language. That seemed to work fine for Android as well. 来源: https://stackoverflow.com/questions/22888154/how-to-get-the-phone-language-with-libgdx

LIBGDX: What is a “viewport”?

自闭症网瘾萝莉.ら 提交于 2019-12-03 18:30:31
问题 This post is related to an earlier post of wanting to learn how to properly render in between LIBGDX and Box2D. I had to understand viewport well before I could proceed. After much code/post readings, I felt the meaning of "viewport" was "the rectangle opening of a lens of the camera that views LIBGDX's Game world, where I can move it about the world to view what I want". But, after more reading, I seemed to be nowhere near the actual meaning. I've read the LIBGDX wiki, and read in the OpenGL

Why do I have lines going across my libgdx game using Tiled?

允我心安 提交于 2019-12-03 17:38:41
问题 I'm using LibGdx and Tiled and when moving around the screen, there are both horizontal and vertical lines appearing on the game. I can post any code you need, if necessary. How do I get these lines to stop? Here's a gfycat gif of the lines: http://gfycat.com/FastUnnaturalAmericanwirehair Edit: Here's a small bitbucket repository, as small as I could get it that has the same glitch in it: https://bitbucket.org/Chemical_Studios/example-of-line-glitch/src

Java LibGDX How to parse an JSON?

我的未来我决定 提交于 2019-12-03 17:35:35
I have a json file with content like this: { players: [ { name: "", hp: 100 }, { name: "", hp: 120 } ], weapons: [ { name: "Desert Eagle", price: 100 }, { name: "AK-47", price: 150 } ] } How to parse it into an array of weapons? I already get content of this file as String. Then I use libgdx JsonReader: JsonValue json = new JsonReader().parse(text); Also I have a class for Weapons: class Weapon { private String name; private int price; } What should I do next to put all the weapons into an array? There is no automatic mapping of parsed Json to Java object in libGDX, so you have to traverse

using ScreenUtils to save screenshot as image in libgdx

时光怂恿深爱的人放手 提交于 2019-12-03 16:56:42
I am using ScreenUtils.getFrameBufferPixels(...) to take a screenshot of the game screen. I want to save the byte array returned by this method as an image in file. I am using libGDX and my focus in android. Niklas It is now fairly easy. Libgdx provides an example . I had to add one statement to get it working. The image could not be saved directly to /screenshot1.png . Simply prepend Gdx.files.getLocalStoragePath() . Source Code: public class ScreenshotFactory { private static int counter = 1; public static void saveScreenshot(){ try{ FileHandle fh; do{ fh = new FileHandle(Gdx.files

LibGDX - properly using Polygon class

限于喜欢 提交于 2019-12-03 16:34:59
I have created Polygon object to wrap my airplane (size of airplane's TextureRegion is 256x74, but size of this one in a game is 70x20). So: TextureRegion[] texRegsAirplane = TextureRegion.split(textureAirplane, 256, 74); Rectangle bounds = new Rectangle(0, 0, 70, 20); Polygon polygon = new Polygon(new float[]{0,0,bounds.width,0,bounds.width,bounds.height,0,bounds.height,0,0}); After that in my update function I update position of it: public void update(float delta){ Vector2 v = getPosition(); v.add(velocity); polygon.setPosition(v.x, v.y); } Then I render polygon to know where it is: public

libgdx and android application. Image as background

你。 提交于 2019-12-03 16:11:46
I am new and I just start my journey with libgdx. I would like to know how I can do image.png in resolution 960x640 as background in my game? This is possible? Thx for advices and forbearance. Maybe you hava a simply tutorial? This is my render class: public void render() { texture = new Texture(Gdx.files.internal("E:/background.png")); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); batch.begin(); batch.draw(texture, 0, 0); batch.end(); } Second question. I need to insert two active images, active means when I click on that image, the next image show me on the screen. I want to implement action