scene2d

scene2d button scaling with libgdx

杀马特。学长 韩版系。学妹 提交于 2020-01-22 20:50:07
问题 I don't know if it is just me, but drawables confuse me. Are they intended to keep the size they are given, or is there a way to scale the image within them? I understand they can use ninepatch to fill certain areas by stretching an image, but I want to scale the image that it stretches. I am using a TextButton for my menu buttons, but they are way too big, and I would love to know how to scale them. I am retrieving the skin from an atlas, which has ninepatch images in it. Here is the

Need help in using scene2d button in libgdx

廉价感情. 提交于 2020-01-15 07:11:48
问题 I am new to libGDX. I am trying to create a custom button by extending com.badlogic.gdx.scenes.scene2d.ui.Button. I want all the button related logic in this class. But I am not getting how to make the click work. I read many tutorials regarding adding Event Listeners but nothing is working. public class RestartButton extends Button { public RestartButton(ButtonStyle style) { super(style); } @Override public void draw(SpriteBatch batch, float parentAlpha) { batch.draw(TextureProvider

Need help in using scene2d button in libgdx

♀尐吖头ヾ 提交于 2020-01-15 07:11:12
问题 I am new to libGDX. I am trying to create a custom button by extending com.badlogic.gdx.scenes.scene2d.ui.Button. I want all the button related logic in this class. But I am not getting how to make the click work. I read many tutorials regarding adding Event Listeners but nothing is working. public class RestartButton extends Button { public RestartButton(ButtonStyle style) { super(style); } @Override public void draw(SpriteBatch batch, float parentAlpha) { batch.draw(TextureProvider

Libgdx: place 2 actors one on another

谁说我不能喝 提交于 2020-01-05 10:29:15
问题 I use libgdx's scene2d built-in UI library to make an UI in my game. I'm interesting how can I draw 2 images(or actors) in a table one on another? I'm looking to the similar like LayerDrawable in Android. Is there any exists stuff to make it? 回答1: There is a Stack widget in libGDX UI library for these purposes. UPDATE : if you want to place one widget on top of another widget and these widgets have different size then you should wrap the smaller widget. Something like: //First add actual

libgdx position window outside of stage

北慕城南 提交于 2020-01-04 02:47:07
问题 I am wondering how to use MoveToAction (or any method) for positioning a scene2d Window outside of the stage. I want the menu to slide in and out. My Stage and my Skin are stored in my world class. These methods work fine for now, while not at all animating it: Window window = new Window("NoteBook", world.skin); ... public void closeBook() { window.remove(); } public void openBook() { world.stage.addActor(window); } This is how I am trying to update these functions to allow animation. Here

Why Libgdx's Table does not accept scale action?

送分小仙女□ 提交于 2020-01-03 08:54:09
问题 I'm using scene2d in libgdx library for creating some UI in my game. I used a Table and I want to take some scaling action when user touches to make a button touching sense. When I used any other "Actor" types like Group and giving it a scale action it works but not Table. this is my Table definition: Table table = new Table(); table.setSize(width, height); table.setPosition(x, y); table.setOrigin(width/2, height/2); table.add(new Label(...)); table.row(); ... And in my touchDown event I give

Scene2d how to handle touched actor?(LibGDX)

六眼飞鱼酱① 提交于 2019-12-29 08:45:47
问题 I have a problem with using scene2d in libgdx. I can't find anywhere a method that allows me to check wheter the actor is touched or not. I can only find methods that told me if actor was touched or released. In my game, when actor is pressed and hold, some things should be done every frame, not only in one moment that I put my finger on it. I want to stop the things when I release my finger. 回答1: You can keep track of this in your InputListener . Create a boolean field isTouched , set to

Why doesn't my approach work to continuously repeat an action till a libgdx scene2d button is pressed and stop it when the button is released?

不打扰是莪最后的温柔 提交于 2019-12-25 14:01:46
问题 I know many questions have been asked to solve similar problem but i could not find an answer to it. Problem : I have made a screen for my libgdx game which looks like the following screenshot. I want the input through touch only.When i press and hold the button labeled 'lower' it decrements the number in the middle once. I want it to keep decrementing until i release the 'lower' button. I have placed the button in a table, which in turn is added on a stage. To achieve what i want i used the

Programmatically perform click on Actor libgdx

痞子三分冷 提交于 2019-12-22 05:58:08
问题 My question is straightforward. I have some ClickListener s added to an Actor. I want to execute a click event on them programmatically. Something like myActor.performClick() ; 回答1: You can also use: InputEvent event1 = new InputEvent(); event1.setType(InputEvent.Type.touchDown); button.fire(event1); InputEvent event2 = new InputEvent(); event2.setType(InputEvent.Type.touchUp); button.fire(event2); This will also show any pressed image change which can be helpful. 回答2: I figured out a

Programmatically perform click on Actor libgdx

那年仲夏 提交于 2019-12-22 05:58:01
问题 My question is straightforward. I have some ClickListener s added to an Actor. I want to execute a click event on them programmatically. Something like myActor.performClick() ; 回答1: You can also use: InputEvent event1 = new InputEvent(); event1.setType(InputEvent.Type.touchDown); button.fire(event1); InputEvent event2 = new InputEvent(); event2.setType(InputEvent.Type.touchUp); button.fire(event2); This will also show any pressed image change which can be helpful. 回答2: I figured out a