libgdx

Rotate Image Clockwise using LibGDX

时间秒杀一切 提交于 2019-11-28 12:26:05
How can we rotate a Image Clockwise using LibGDX? what i am looking is when a image is loaded,suppose a star, i need to rotate it from beginning of screen to end of the screen horizontally, with star rotating,how can i do that in libgdx? Rahat Ahmed When you draw the Texture with your SpriteBatch, you can use one of the draw functions that includes rotation. This javadoc has all the draw functions: SpriteBatch You can keep a variable for position and rotation, and increase the rotation and x component of the position each time you render to make it rotate while moving horizontally. Libgdx

Managing assets between desktop and device version in libgdx

只愿长相守 提交于 2019-11-28 12:06:44
I'm building a little Android game using libgdx. For now I have a copy of the game's assets in the desktop project folder and the Android project folder. For some strange reason I have to access those files differently in each of the two versions. This works fine in the desktop app but gives me a FileNotFound exception in the android app: Texture texture = new Texture(Gdx.files.internal("assets/someImage.png")); If I remove the "assets" from the filename it's the other way round (Android works, desktop crashes): Texture texture = new Texture(Gdx.files.internal("someImage.png")); I'm not sure

Getting AdView to work

我的梦境 提交于 2019-11-28 12:04:42
问题 I am developing a game in libgdx. I read the official docs and tried to integrate MobClix Ads in my App but eclipse can't resolve this constructor for ADView class: (for Example): AdView ad = new AdView(this, AdSize.BANNER, "a14d91b10f12454"); This line of code give me an error. Maybe my import is not correct? I import this: import com.google.android.gms.ads.AdSize; import com.google.android.gms.ads.AdView; And the same for: adView.loadAd(new AdRequest()); I tried to search for an answer but

Using LibGDX, how do you have an animation using seperate images ?

对着背影说爱祢 提交于 2019-11-28 11:51:02
I'm learning how to make games using LibGDX and I'm trying to make a small platform game (using Eclipse). I made 4 images on the main character running to make an animation when he moves. However, I can't find anything online to show me how to make an animation without using a SpriteSheet. How do you make an animation using 4 different images ? First of all: You should not use different images. Maybe for your player it does not matter much (because there is only one) but in general you should always use sprite sheets, a.k.a. TextureAtlas . However, it is possible without it by using different

Libgdx Quiz- Using SQLite Database?

与世无争的帅哥 提交于 2019-11-28 11:44:27
问题 I have been learning Android development and using the Libgdx framework for over a month now and want to create a test app. The app i want to create is a quiz and im stuck on the situation on how i am going to store all the questions, answers. Being a web developer for many years i of course thought of a database but libgdx doesn't have much support for sqlite which leaves me stuck on how to achieve the storing without using a database. Does anyway know any way to use sqlite with libgdx or

Libgdx and Box2d Detect Collision of two specific bodies

…衆ロ難τιáo~ 提交于 2019-11-28 11:34:17
问题 I have two bodies, both dynamic, one of them I have turned off the gravity and only want to turn it on when it is hit by my other body. I know I can set my own contact listener but I want to specify an action only if two specific bodies touch. Any one have any guidance? 回答1: U can set the userdata of the body and use it like that public class GameColiision implements ContactListener { public GameColiision() { } @Override public void beginContact(Contact contact) { // TODO Auto-generated

How do libgdx detect keyboard presence

早过忘川 提交于 2019-11-28 11:19:50
When writing in the Textfield, I need my textfield to move upwards in order to let the textfield be visible when the keyboard pops up. Does libgdx have some kind of method which returns true if the keyboard is visible and false when it is down? The following code will detect when you press a textfield, prevent it from showing the keyboard and then open a native dialog that moves up and down with the keyboard. It will take the input from the native dialog and finally put it back in your textField: textField.setOnscreenKeyboard(new TextField.OnscreenKeyboard() { @Override public void show

Libgdx light without box2d

落花浮王杯 提交于 2019-11-28 09:26:22
I just started creating a game using libgdx. It is a top down 2d shooter using scene2d ui. Now i thought, that i could add darkness and light to some levels, but i don't want to rewrite everything using box2d. I don't need realistic shadows just some kind of ambient light and a lightcircle arround my character, which is not affected by walls and other obstacles arround him. So i wanted to know if there is any kind of lightsystem in libgdx? Or can i use box2dlights without using box2d bodies/world...? Thanks Unfortunately there is nothing like this already provided by LibGDX. But you can easily

How to detect when an actor is touched in libgdx?

情到浓时终转凉″ 提交于 2019-11-28 09:06:27
问题 I am using "Gdx.input.isTouched()" in the render method of my Screen method, to know where is touched, but when the touch is dragged in the screen, it also activates the events i want only when an actor is touched. Is there any listener to know when an Actor is touched, but the event is not the dragged one, im doing it with sprites. 回答1: See this wiki page about scene2d in LibGDX. Specifically the part about Input handling. Basically you have to override one or more of these methods in your

LibGdx, How to handle touch event?

陌路散爱 提交于 2019-11-28 08:55:32
问题 I am LibGdx Newbie, and trying to make my iceCream image touchable. I like to know how to set the input-process(by touch on screen). Do I need to make another class? When I try to implements the input-process to my Prac1 class, JAVA doesn't allow me to implements without changing the class abstract. To be specific, I like to make it whenever the user touch the image ,it counts the number of touch. Here is my code and Thank you for help. import com.badlogic.gdx.ApplicationAdapter; import com