libgdx

LIBGDX: How do I draw a filled polygon with the shaperenderer?

最后都变了- 提交于 2019-12-04 02:08:45
I have defined a shape using an array of vertices: float[] points = new float[]{50,60,50,70,60,70, 60,60,50,60}; And I am drawing this here: shapeRenderer.polygon(floatNew); This just gives an outline of the shape. How do I fill it with colour? Thanks Currently, ShapeRenderer supports polygon drawing (by line) but not filling. This code is clipping the polygon on triangles, and then drawing each triangle separately. Edit ShapeRenderer.java like this: EarClippingTriangulator ear = new EarClippingTriangulator(); public void polygon(float[] vertices, int offset, int count) { if (shapeType !=

Draw a smooth line

≡放荡痞女 提交于 2019-12-04 01:44:41
I am developing a game using libgdx and i want to draw a smooth line using shape renderer. shaperenderer.begin(ShapeType.Line); shaperenderer.line(fisrstVec2,secondVec2); shaperenderer.end(); I have tried Multi Sample anti aliasing from libgdx blog. I have also went through Anti aliased filed shape in libgdx but unfortunately these line is not in latest verson of libgdx. Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH); Gdx.gl.glEnable(GL10.GL_POINT_SMOOTH); Enable anti-alising in the configuration: For Desktop: LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.samples = 2

How to detect if a texture has been touched libgdx WITHOUT scene2d

为君一笑 提交于 2019-12-04 01:42:24
问题 I want to know if there is a away to detect a touch on a certain texture without using scene2d. The Gdx.input.isTouched() detects a touch on the WHOLE screen, is there a way i could use something that detects a touch on a texture without scene2d? 回答1: Of course there is, I also never use screne2d. in your update method if(Gdx.input.isTouched()) { Vector3 tmp=new Vector3(Gdx.input.getX(),Gdx.input.getY(); camera.unproject(tmp); Rectangle textureBounds=new Rectangle(textureX,textureY

Getting Stage coordinates of Actor in Table in libGDX

时光总嘲笑我的痴心妄想 提交于 2019-12-04 00:46:37
问题 I want to create a floating help bubble to introduce the basic functioning of my game. This bubble should float above the Actor I want it to explain, like shown in the picture below. To accomplish this, I want the coordinates of the Actor, in this case the left button, and then I can add the bubble Actor to the Stage in front of everything else. The last part is easy enough, but I'm struggling with retrieving the actual coordinates of the button, as it is in a table. The two buttons are added

Using SVG files with libgdx

三世轮回 提交于 2019-12-03 23:45:24
I'm planing to create tablet app. I would ask for some guidance. I have pictures in SVG format like this one . With SVG it is easy, You just change fill parameter to different color but as I understand, there is no easy/stable svg processing to use with libgdx. I still want to use svg files to create/store images for my app. What processing path would You recommend? Is there an easy way to convert svg paths/shapes for com.badlogic.gdx.math.bezier or polygon objects and then draw them on screen/get user input (tap) inside this shapes? Or should I use different objects/path? Shapes could be

Libgdx game crashes on Android

三世轮回 提交于 2019-12-03 23:04:08
I made a game using libgdx and it runs fine on both desktop and android before. I'm not sure if its because I started using box2d physics engine and liquidfun particles,what basically happens is that when I click play on my game it start loading then after loading it should go to the gameScreen, but it crashes then says "Unfortunately, myGame has stopped". error message: E/AndroidRuntime: FATAL EXCEPTION: GLThread 3764 Process: com.nivekbryan.puffypuff, PID: 8416 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/badlogic/gdx/physics/box2d/World; I followed this setup tutorial on how

libGDX: How can I crop Texture as a circle

帅比萌擦擦* 提交于 2019-12-03 23:03:50
问题 I achieved my goal with android development as shown in this link Cropping circular area from bitmap in Android but how can I achieve that with libGDX framework? I tried to do it with Pixmap but not succeeded with me. Anyone can Help me to achieve that. 回答1: I don't know if there's an easier way, but I made a method for working with masks and combining the mask with the original pixmap into a resulting pixmap. public void pixmapMask(Pixmap pixmap, Pixmap mask, Pixmap result, boolean

IntelliJ can't find any LibGDX packages?

久未见 提交于 2019-12-03 22:53:37
问题 I have just switched to Ubuntu and I've installed IntelliJ IDEA 14 Community Edition. When I imported my existing project, I found that IntelliJ can't seem to find any of the LibGDX dependencies. I installed Gradle beforehand. I've tried using the Gradle wrapper included with the IntelliJ project to and saying ./gradlew --refresh-dependencies , but this doesn't seem to do much of anything. My external TweenEngine packages were loaded just fine. It seems to only be with the LibGDX packages

LibGDX - Custom Click Listener?

梦想的初衷 提交于 2019-12-03 22:49:37
问题 I want to make my own Button class, that will have a Sprite, and whenever i touch it it will grow or rotate, etc, the class will have also a Draw and Update function. To check if I touch it i can check if the sprite rectangle contains the position of the touch in the touchdown and touchup method of the screen class. I don't want to do that, i want to make something like android button click listener, is that possible? Something like myCoolButton.setOnClickListener(new

libGDX - Add scores & display it at top left corner of the screen?

本秂侑毒 提交于 2019-12-03 22:47:59
Here is the sample code of a simple game in libGDX. When a rain drop falls into a bucket,score should be increased by one. And total score should be shown at the top left corner. If 3 drops are missed than display GAME OVER. I know to increase the score but i don't know to display it. Thank you. public class Drop implements ApplicationListener { Texture dropImage; Texture bucketImage; Sound dropSound; Music rainMusic; SpriteBatch batch; OrthographicCamera camera; Rectangle bucket; Array<Rectangle> raindrops; long lastDropTime; @Override public void create() { // load the images for the droplet