libgdx

Android Libgdx and collision detection

大兔子大兔子 提交于 2019-12-08 06:42:45
问题 For my android game I use Libgdx and I detect the collision between Bob (Omino) and Plant (Pianta) with this code that works fine : Assets.class pianta = new Animation(0.5f,new TextureRegion(items, 160, 384, 64, 96), new TextureRegion(items, 224, 384, 64, 96)); Pianta.class public class Pianta extends GameObject { public static final float PIANTA_WIDTH = 2; public static final float PIANTA_HEIGHT = 3; public static float stateTime; public Pianta(float x, float y) { super(x, y, PIANTA_WIDTH,

libgdx game how to display pause screen when user click on pause icon

风格不统一 提交于 2019-12-08 06:42:30
问题 In libgdx how show pause screen when user click on pause and it should be layer over the present screen and it should close the screen when user click on resume how can i implement it in libgdx. 回答1: I don't like the suggestion about using native Android View here, this can be done neatly inside libgdx itself. I would have had some variable that defines the current state of the game. If pause button is pressed, or the game is paused by android (for instance if the user presses the home button

How do I make a Box2D wrap around world?

妖精的绣舞 提交于 2019-12-08 06:29:57
问题 I want to make a wrap around game effect where an object would go off the screen from the x-axis one side and reappear in a new y-axis position on the other side of the screen. The width is 250 pixels, so basically it would pass (0, y1) and would reappear at (300, y2). a.applyForceToCenter(aMovement, true); a.applyTorque(3000, true); FixtureDef fDef = new FixtureDef(); BodyDef ballD = new BodyDef(); ballD.type = BodyType.DynamicBody; //random location for asteroid int aLoc = (int) (aLocation

Deleting and creating body in libGDX

妖精的绣舞 提交于 2019-12-08 05:34:16
问题 I have a problem with deleting/creating bodies in libGDX (box2d). I get a fatal error. Log: http://pastebin.com/fXWXpe8N I try to destroy bodies after collision. ~90% bodies are deleted good, without errors and crashes. But sometimes it happens. How can I fix this error? I have no idea. Contact: private void bulletGround(Contact contact) { Body bodyA = null; Body bodyB = null; if(contact.getFixtureA() != null && contact.getFixtureA().getUserData() != null && contact.getFixtureA().getUserData(

Why do textures flicker when camera moves?

北慕城南 提交于 2019-12-08 05:06:28
问题 I implemented a top view camera which moves with the player, only a bit slower using camera.position.lerp . The problem is that the textures are flashing (flickering) a little because i have scaled my textures. If I use normal size of textures the flickering stops. Does anyone have any ideas on how to move the camera with zoom (or textures scaled - same thing) without getting the textures to flicker (or flash)? I use linear filtering and load every asset from an atlas. I saw this problem on

Couldn't load TextureAtlas from zip archive via AssetManager - libgdx

喜欢而已 提交于 2019-12-08 04:32:33
问题 I have 2 instances of AssetManager: one for basic textures and one for high quality textures. Basic textures are located in "android/assets" folder and high quality textures are packed in zip file. Content (file names) in this folders are the same - there are only better quality textures in zip archive. AssetManager throws an exception: "Couldn't load dependencies of asset: teamLogo.png" when I'm trying to load TextureAtlas from zip file. When I'm loading Texture file everything is ok.

spotlight not working in libGDX

烂漫一生 提交于 2019-12-08 03:52:52
问题 I was playing around with spotLight in libGDX. I used this code to project the light source in -y direction. To my surpise, my floorModel was completely black. I went to docs and found this interesting fact: Note that the default shader doesn't support spot lights, you'll have to supply your own shader to use this class. I think this may be the reason the what spotlight isn't working. I have however found 0 examples of setting up spot light properly. Could you provide a simple example on

LibGDX FreeTypeFontGenerator NoSuchField exception

元气小坏坏 提交于 2019-12-08 02:59:49
问题 Right now, I'm building a small game with LibGDX in Java, and I want to use a TTF font. I've added gdx-freetype.jar and gdx-freetype-natives.jar to my build paths, but when I get to running my application, I get a "java.lang.NoSuchFieldError: id" error. The code responsible: FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("data/Prosto.ttf")); BitmapFont font = generator.generateFont(12); generator.dispose(); I read somewhere it might have something to do with

JsInterop “com is not defined”

我的梦境 提交于 2019-12-08 02:55:47
问题 Trying to communicate with LibGDX project per Javascript with JsInterop. I am following the "Exporting a Java type to JavaScript" example here. It does not work: Uncaught ReferenceError 'com' is not defined . I am not getting any errors with gradle though. I have already: checked that generateJsInteropExports is enabled: My GdxDefinition.gwt.xml : <module rename-to="html"> <inherits name='com.badlogic.gdx.backends.gdx_backends_gwt' /> <inherits name='com.badlogic.gdx.physics.box2d.box2d-gwt'

runTime error in libGDX

旧城冷巷雨未停 提交于 2019-12-08 02:51:50
问题 in past i worked with my projects and everything was good. but recently, i have this errors: 06-02 04:52:27.954: W/dalvikvm(344): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/badlogic/gdx/backends/android/AndroidApplication; 06-02 04:52:27.954: W/dalvikvm(344): Class init failed in newInstance call (Lcom/Jumper/ProjectAndroidActivity;) 06-02 04:52:27.963: D/AndroidRuntime(344): Shutting down VM 06-02 04:52:27.963: W/dalvikvm(344): threadid=1: thread exiting with