libgdx

Using MVC with libgdx scene2d [closed]

。_饼干妹妹 提交于 2019-12-01 08:33:49
I started developing a game using libgdx. It is actually my second try because when i started the first try i did not know enaught of libgdx. In my first try i had an actor subclass with the logic and the texture in it. Then i started reading Gustavo Steigerts tutorial and i saw that he tryed to separate logic and view. I tryed to do the same, but the view is my actor subclass with informations about size and position, so it has to do the collision detection, which is part of the logic. Also if you search on Google you find that with Scene2d you cannot do the MVC. So is there a way to

libGdx How to use images or actor as body

你说的曾经没有我的故事 提交于 2019-12-01 08:07:45
问题 I gone through the libGdx wiki/tutorial but I didn't find example to use an image or an actor as a physics body. In my game I am adding an actor to the stage. But I want to add this actor or sprite image as physics body. I have to drag this actor and even want to detect collision with other bodies. please give me reference if you have. Thanks 回答1: This is a bit tricky. You don't use an image or an Actor as a physics body. You will need to implement something like a new "PhysicsActor" which

libgdx Viewports - Why when I use FitViewport the touch input x and y is not accurate?

余生长醉 提交于 2019-12-01 07:55:21
问题 libgdx Viewports - Why when I use FitViewport the touch input x and y is not accurate? 回答1: Use viewport.unproject() instead of camera.unproject() so the cropping of the FitViewport is taken into acount. 来源: https://stackoverflow.com/questions/38226563/libgdx-viewports-why-when-i-use-fitviewport-the-touch-input-x-and-y-is-not-acc

How do I make a libGDX Desktop application resizable?

喜你入骨 提交于 2019-12-01 07:34:06
问题 libGDX Applications must implement the .resize(int width, int height) method, so I figured that resizing a libGDX app is not a big deal, but I found no way to make the actual application JFrame or whatever that is draggable as with JFrame.setResizable(true). Is that simply not possible with libGDX ? 回答1: If you use gdx-backend-lwjgl for you desktop app, then you can use: LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.resizable = true; new LwjglApplication

Using MVC with libgdx scene2d [closed]

大城市里の小女人 提交于 2019-12-01 07:24:27
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . I started developing a game using libgdx. It is actually my second try because when i started the first try i did not know enaught of libgdx. In my first try i had an actor subclass with the logic and the texture in it. Then i started reading Gustavo Steigerts tutorial and i saw

libGDX get pixel color from sprite or texture

ε祈祈猫儿з 提交于 2019-12-01 07:15:32
I was searching it on net but i wasn't able to find any solution. I have a sprite or a texture and when i touch it i want to get pixel color from touch coordinates. so I have: if (Gdx.input.isTouched()) { Rectangle spriteBounds = sprite.getBoundingRectangle(); if (sprite.contains(Gdx.input.getX(), Gdx.input.getY())) { //and here something like //Color color = sprite.getPixelColor(Gdx.input.getX(), Gdx.input.getY()); } } Is it possible? Thank you :) Something like the following might work, but is untested. You can get the color via the Pixmap of the sprite's Texture . You need to make sure that

libGDX set rotation point 3D

梦想的初衷 提交于 2019-12-01 07:05:02
问题 I have two objects base and weapon and I need to set rotate point of weapon to position of base. public Test(){ position1 = new Vector3(0,0,0); baseModel = modelLoader.loadModel(Gdx.files.getFileHandle("data/models/tower/bases/base1.g3db", FileType.Internal)); base = new Base(baseModel, position1); position2 = new Vector3(3,10,5); weaponModel = modelLoader.loadModel(Gdx.files.getFileHandle("data/models/tower/weapons/weapon2.g3db", FileType.Internal)); weapon = new Weapon(weaponModel,

LibGDX Moving a Rotated Camera

跟風遠走 提交于 2019-12-01 06:43:36
I've come to a situation in my application, built using LibGDX, where I need the camera to be able to rotate, and also be moveable by the user, as well as being able to be zoomed. My camera controls for moving and zooming the camera work beautifully, however, when the camera is rotated, the camera is then moved based on that rotation. For example, if the camera is turned 45 degrees to the left, and the user drags to the right to move the camera, it will move towards the upper right, because that is where the right side of the camera is now pointing. Instead, I need the camera to always move

Libgdx box2d body moves slow

只愿长相守 提交于 2019-12-01 06:29:30
This is a very simple scene with box2d. I tried different viewports and different screen sizes. I could not figure out why the body drops very slow. Actually, I am not quite sure that it is slow, the reason is maybe the viewport settings etc. This is main class: public class Main extends Game { LevelScreen levelScreen; @Override public void create () { levelScreen = new LevelScreen(); setScreen(levelScreen); } @Override public void render () { super.render(); } } And level screen: public class LevelScreen extends Stage implements Screen { private Batch batch; private Camera camera; private

Best way to detect the touched object (moving) from collection in libgdx

喜欢而已 提交于 2019-12-01 06:11:00
问题 This is my first attempt in game development. I just started experimenting libgdx and understanding the different aspects of game programming. I looked at the sample projects, i can understand the overall architecture of the libgdx game. But to get hold of the basics of game dynamics, i started playing with low level stuff like how to draw simple shapes, how to move them, how to handle collision like that. So i planned to write a dead simple android game(Its not even a game for sure). This is