libgdx

Android. LidGDX. Following CatmullRom spline produces weird results in 3D

旧时模样 提交于 2019-12-24 12:10:00
问题 I have a 3D-object that is navigating the CatmullRom spline. The code I'm using is taken from Xoppa's answer here: Xoppa's answer There are 2 ways of aligning object along thre spline. I tried both of them. And have weird results with both. Option 1 (it mostly OK but have a weird rotations occuring...see image below): Option 2 (removes issue from Option 1 but everything else is not okay..see image below ): My spline: pointsArray = new Vector3[21]; pointsArray[0] = new Vector3(-5, -2, 2);

Draw string with BitmapFont

回眸只為那壹抹淺笑 提交于 2019-12-24 12:07:56
问题 Sorry for that stupid question but I'm a quiet noob. I can't figure out how to draw Bitmap Font in Libgdx. Well, I've used HIERO v2.0 tool to make BitmapFont file. Then I initialize it in code: BitmapFont font = new BitmapFont(Gdx.files.internal("data/fonts/Georgia.fnt"), Gdx.files.internal("data/fonts/Georgia.png"), false); But when I try to draw it on screen: game.batch.begin(); font.draw(game.batch, "Text string", game.screenWidth * 0.5f, game.screenHeight * 0.5f); game.batch.end(); I get

Libgdx set ortho camera

旧街凉风 提交于 2019-12-24 11:25:19
问题 I'm having problems setting my orthographic camera to the bottom left part of my screen (0,0) public GameScreen(Main game) { this.game = game; Width = 200; Height = 300; view = new ExtendViewport(Width,Height); camera = new OrthographicCamera(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()); camera.setToOrtho(false,Width/2,Height/2); camera.position.set(Width,Height,0); camera.update(); play.Player1(); staple = new Stage(); staple.addActor(play); staple.addActor(pile); Gdx.input

LibGDX 'MyFirstTriangle' example crashes on startup

拈花ヽ惹草 提交于 2019-12-24 11:16:54
问题 Upon finishing this tutorial for the libGDX android library, the desktop project runs fine and there are no errors anywhere that eclipse points out. When I go to run it on my Nexus 7, (running Android 4.3) the white screen flashes (presumably the default background of the app) and then it goes back to the home screen and says "Unfortunately my-first-triangle-android has stopped." This is the error I get from LogCat: 08-02 20:11:52.940: E/AndroidRuntime(4095): FATAL EXCEPTION: main 08-02 20:11

How to press a key programmatically in a TextField?

这一生的挚爱 提交于 2019-12-24 11:02:04
问题 I have a TextField , and I want to press the switch charset button programmatically. I've tried this, but I get a NullPointerException . myTextfield.addListener(new FocusListener(){ public void keyboardFocusChanged(FocusEvent event, Actor actor, boolean focused){ if(focused){ InputEvent ie = new InputEvent(); ie.setKeyCode(Keys.SWITCH_CHARSET); actor.fire(ie); } } }); This is the log cat error 回答1: You need to set the type of the event. That's what causes the NullPointerException , which you

Using LibGdx without AndroidApplication?

ε祈祈猫儿з 提交于 2019-12-24 10:59:28
问题 In my project, I am interested only in a particular part of LibGDX, that is viewing 3D model and animating it, no inputs or other functionality is needed. As I need to view 3D models in a RecyclerView.ViewHolder within a RecyclerView.Adapter As I have searched, I found that I need to get the view at AndroidGraphics class, ex: GLSurfaceView However, I have no idea how to do the initialization without AndroidApplication , would this be possible? Any idea? 回答1: You can create a libgdx view in

Allowing both landscape options and accelerometer with libgdx

南楼画角 提交于 2019-12-24 10:53:45
问题 I've completed the SimpleApp tutorial for libgdx. I have changed the controls for the game to use the accelerometer instead of touch input, in the following way: In MainActivity.java cfg.useAccelerometer = true; In DropGame.java float acc = Gdx.input.getAccelerometerY(); bucket.x += acc * 120 * Gdx.graphics.getDeltaTime(); My question is, how do I allow both landscapes? I would like to be able to turn my device 180 degrees from one landscape orientation to the other, and have the game rotate

Box2d Bodies that are really close together, are getting “stuck”

血红的双手。 提交于 2019-12-24 10:40:49
问题 Im using a tiled tmx map, and I created a class that adds bodies to each tile within a certain layer. This has been working great so far except for when a character or an enemy moves around on the screen, its body gets stuck on an edge between two tiles. This seems to happen "sometimes" and in certain spots. Jumping makes u unstuck but its annoying when it happens, and i tried increasing the position iterations, but the problem keeps reoccurring. Heres what my game looks like: http://i.stack

how do I pause the SpriteAnimation in libGDX with a button to be able to view the current frame when pause button is pressed?

拜拜、爱过 提交于 2019-12-24 10:38:27
问题 I was trying to pause the animation with a pause/resume button, by doing this : public static int gameStatus = 1; public int gamePaused = 0; public int gameRunning = 0; public void create(){ gameRunning = 1; //.. code } public void render(){ if(gameStatus == gameRunning){ //some code .. pause.setClickListener( new ClickListener() { @Override public void click(Actor actor, float x, float y) { System.out.println("pause is pressed"); //to stop the animation at a particular frame spriteBatch

Can libgdx Particle Effects use texture regions?

回眸只為那壹抹淺笑 提交于 2019-12-24 08:39:09
问题 I have all of my images for a libgdx project in a single texture. I'm about to add some nice particle effects, but the documentation implies that each type of emitter requires a separate graphics file for its particle. Is that true? Or, is there a way of specifying a region of a texture to be used as the particle image, so that I may still keep all my images in that single file? 回答1: Yes it can but you need to have the texture inside of an TextureAtlas . Take a look at this article for it.