Hot answers tagged

11

Dialog is better suited for modal pop-up windows, and it includes a "button" and "content" table already in the window (as the docs say). You can grab these tables with getButtonTable() or getContentTable(). The dialog makes it easy to work with pop up windows. For example, here is a confirmation dialog: Dialog dialog = new Dialog("Warning", skin, "dialog")...


9

Expand: expands the cell that the actor is currently placed in to occupy the largest possible area without changing other cells size. For example if the cell is 50 x 50 and there is 50px of empty space to the sides of the cell it will resize to 100 x 50. Only changes the size of the cell, not the actor. Fill: makes the actor occupy the entire space of the ...


6

According to the official LibGDX wiki, capture listeners are called before "normal" listeners to give you a chance to intercept the events. (i.e. Active window cancels click on button under it) First, during the "capture" phase an event is given to each actor from the root down to the target actor. Only capture listeners are notified during this phase....


5

In the second case it is not drawing because the constructor with no arguments doesn't set a width and height for the image, however the constructor that takes the drawable obtains the values from it. To fix in your case: Texture texture = new Texture(Gdx.files.internal("cookie.png")); Image itemImage = new Image(); itemImage.setPosition(10, 10); itemImage....


5

I found out a solution to your other problem. To allow the typing of a dot you should create your own implementation of TextFieldFilter like this. public class DigitFilter implements TextFieldFilter { private char[] accepted; public DigitFilter() { accepted = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.'}; } @Override public ...


4

The most likely problem is that in one of your actor's draw calls you are forgetting to reset the batch's color. This would cause alpha transparency to carry throughout your entire stage. Make sure you always reset the batch's color at the end of a draw call where you manipulate it. Here is an example: public void draw (Batch batch, float parentAlpha) { ...


3

You can change the Actor that the Value acts on by supplying the actor (in your case your table) in the constructor like so: table.add(button).width(Value.percentWidth(.75F, table)); This will make Value use that actor for the Value#get(actor) method instead of the default parent actor.


3

The cause of this problem is actually the way I constructed the ScrollPane object. I called the ScrollPane(widget) constructor without providing the skin which constructs the ScollPane like this: public ScrollPane (Actor widget) { this(widget, new ScrollPaneStyle()); } this basically means that for styling the ScrollPane it uses an empty ...


3

The problem is, that I should not add a listener when I'm using the "button()" method, the correct way to use this method is, simply add the button, and as a second argument, you pass an object to recognize your button, once in the result method, you use an if to compare the object passed to know which button you clicked, just like this: private class ...


3

There is an option to do this: First of all you need to find out what your smallest size of a column is, therefore you have to merge all rows into one and pick the smallest width of all columns. the numbers in the picture are displaying the width of the columns. Knowing your smallest width (in my example it's displayed as 1) allows you to create a table ...


3

A nice way to implement what you are trying to achieve would be to use a SequenceAction and built in libgdx actions : tooltip.addAction(Actions.sequence( Actions.show(), Actions.fadeIn(1f), Actions.delay(4.5f), Actions.fadeOut(1f), Actions.hide()) ) Actions.show() basically call setVisible(true) on your actor and Action.hide() call ...


3

You don't initialize your currentframeRight and currentFrameLeft in the constructor. Put this in the constructor of WalkAnimate: currentFrameRight = walkAnimationRight.getKeyFrame(0f, true); currentFrameLeft = walkAnimationLeft.getKeyFrame(0f, true); So it looks like this: public WalkAnimate () { walkSheetRight = new Texture("ninjaWalkRight.png")...


3

How does this look? (Green and red lines are only there for debugging) What I did to achieve this was to first separate the card into three columns and five rows; then I had the Cost, Life, Attack, and S field occupy the small 1st and 3rd column and the Image, Title, and Description occupy the large 2nd column. I then used a Stack (docs) to stack the table ...


3

Quoting the javadocs of the Button class: Each time a button is clicked, the checked state is toggled. So the buttons are probably checked, you just can't see it. The reason for not being able to see it might be that your Skin (or ButtonStyle) does not contain a drawable for the checked state. This means that the button will not show when it is actually ...


2

The reason why scrolled is not working is... To activate scrolled in Scene2d, we need this one line stage.setScrollfocus(actor);


2

According to the source history on Actor , the hasActions method was added 7 days ago. Get latest and I think it should work for you.


2

I had the same problem with a window (scene2d.ui.Window). It would propagate click and other events though it shouldn't. I solved it by doing this: window.addListener(new ActorGestureListener()); As simple as that. Not sure if this is the correct way to do it or if it has some undesirable side effects, but it worked in my case.


2

You shouldn't call dispose directly on a Texture loaded by an AssetManager, they are disposed the the AssetManager is cleared or disposed or if you call unload on the AssetManager and pass the Texture. The reason you shouldn't dispose assets from an AssetManager is that they can be shared between many other assets (two fonts may use the same texture for ...


2

Open ui_skin.atlas in your GDX project and change the 3rd line to: filter: Linear,Linear It will apply linear min/mag filters to textures and they should look a little bit better. Main LibGDX skin is 'pixelated' by default. You can search here for some custom skins: https://github.com/czyzby/gdx-skins or implement your own in Photoshop/Illustrator with ...


2

You can do this using: selectBoxStyle.listStyle.selection.setTopHeight(10);


2

You can create an Action that is shared across Actors and that counts down a value to zero, then use this state in conjuction with a SequenceAction to find out when a series of Actions have completed. For example, with an Action like this; public class CountDownAction extends Action { private int count; @Override public boolean act(float delta)...


1

libgdx provide a utility class called viewport to deal with different screen resolutions problem , each time the screen resolution changes you have to update the viewport: private Viewport viewport; private Camera camera; public void create() { camera = new PerspectiveCamera(); viewport = new FitViewport(800, 480, camera); } Whenever a resize ...


1

Why not just use it with a Stage and Table as intended? Stage stage = new Stage(); Table table = new Table(skin); // You can skip table and add it directly to the stage as well. Touchpad touchpad = new Touchpad(deadzoneRadius, skin); stage.addActor(table); table.add(touchpad); Gdx.input.setInputProcessor(stage); // Stage will handle all input and updates ...


1

There are a lot of different kinds of transition. To concretely answer this question clarify which kind of transition you are looking for. If you want to do a blended transition, you'll need to render a single frame of the old scene to a buffer, render a single frame of the new scene to a buffer, and then do the transition animation. Here's a pointer for ...


1

It seems that if the VerticalGroup is added to another layout, then it works. Looking at the code, this is due to VerticalGroup also being a Layout, and so it's prefWidth/Height are used instead of the getWidth/Height methods. I got around this by manually setting the size to the pref. size. setSize(getPrefWidth(), getPrefHeight()); Note, that you don't ...


1

I would comment on Daedrics answer but I don't have enough rep. His detailed explanation is great and is pretty much already handled by LibGdx's HorizontalGroup() widget, most of the actual layout calculations are already taken care of using the .center() and .space() methods. What you need to do: Create a HorizontalGroup() to hold the cards in your hand ...


1

It looks like your problem could be that your MyActor class does not report it's width and height to the parent Actor. Just because you have an Actor that has some other Actors as members doesn't mean the "parent" Actor will know how tall and wide it should be to accommodate all of them. By querying the preferred size of the child Actors you can return more ...


1

I know its late but it might help someone, basically when we create actors, in the act() we'll have to set its layout boundary relative to the parent. Layout boundary helps identify the size of the custom actor. someActor.setBounds( getParent().getX()+getX(), getParent.getY()+getY(), someActor.getPrefWidth(), someActor.getPrefHeight() );


1

Scene2d would probably be good to use for a visual novel, it's not limited to UI, you could design a whole game with it if you wanted to. You could make a scene2d stage and then add back and forward buttons to it. You could have several buttons that you change label on and use for selecting what your characters says/does. If you find something scene2d can't ...


Only top voted, non community-wiki answers of a minimum length are eligible