scene2d

How do I make a ProgressBar work in LibGDX?

自古美人都是妖i 提交于 2019-12-08 16:47:18
问题 I'm trying to understand how to use a ProgressBar in LibGDX. I have created the bar but I don't know how to make it works. I want to duplicate the knob in order to fill the bar(background line) in 60 seconds. I know how to manage about the time, but there is no method in ProgressBar's class to fill the bar with the knob. At least, I haven't seen it (or I don't understand how, possibly). Here is my code: ProgressBar's code: skin = new Skin(); Pixmap pixmap = new Pixmap(10, 10, Format.RGBA8888)

Scene2d tables turn black on one phone after a few game resets

浪子不回头ぞ 提交于 2019-12-08 08:17:07
问题 My game screen uses both Scene2d and normal libgdx sprites. I use scene2d for the pause menus which contain some tables and textbuttons. All is ok on the pc. All is ok also on two mobile phones I'm testing the game on, but I have a pb on a third phone. It seems that after a restart or two of the game level all the scene2d elements that are supposed to appear on the screen have turned black. They are still responsive, meaning the buttons do what they are supposed to do, they move rotate and

Game crash if interrupted while Splash Screen is on - LIBGDX

本小妞迷上赌 提交于 2019-12-07 05:59:34
问题 I have a splash screen and a menu screen class that loads all my texture atlases and skins for the menu and processes lots of stuff. If I put the constructor for the menu screen in the SplashScreen constructor or in the create() method of my main game class (MyGame class) then it would pass a lot of time with no splash screen render image on the phone while the whole stuff loads so I have delayed the loading of the menu class to the second frame render (gets called in the SplashScreen render

Libgdx | Scene2d | Set background color of table?

风流意气都作罢 提交于 2019-12-07 05:19:32
问题 I am creating a menu (like the one is flappy bird, when you die it pops up over the play screen). I created a class that extends table, and I want to set the background of the table to white. Is there a way to do this? 回答1: I see that the problem has already been solved, but there are others asking to see the code and I can't comment yet. Here's an implementation of a similar solution, with the exception that a class will be made available for instantiation (so that the Table background color

Proper using of scene2d's Stage in a game with a huge world

谁说胖子不能爱 提交于 2019-12-07 00:50:07
问题 If the whole "game world" is thousands of times wider than a viewport, and if I want to use scene2d to manage game objects as Actor s, should I create Stage object as wide as the whole world, or should the Stage be some area around current viewport but not the whole world? In other words, does a Stage with greater width and height consume more memory itself, even if I render objects only on a small viewport-sized part of it? 回答1: I think you misunderstood what exactly a Stage is. A Stage

libgdx - how to add background image in stage?

纵饮孤独 提交于 2019-12-06 21:27:04
问题 I am learning libgdx but i am stuck at a point.. I have added a button in my stage , now i want to add a image in the stage so that the image looks as the background image to the button.i mean to say that the button should lie on the image. I have been looking tutorials but not been able to do that. How can it be done? any help? 回答1: The only thing you need to do is to draw the background, before drawing the Button s. There are a few possible ways to do that: - You can add the background as

How to get the world coordinates of a point in a child actor?

限于喜欢 提交于 2019-12-05 12:52:48
I have Group objects that consist of other Group objects, that finally consist of Actor objects. Now, when the groups and actors are rotated, offset and scaled, the coordinates in the "world", or in relation to the root node change. How do I get the world coordinates of a point in an actor's local space? To illustrate a bit more, here's an example of what I want: Group parentGroup; Actor childInGroup; ... parentGroup.addActor(childInGroup); childInGroup.setPosition(10f, 15f); childInGroup.setRotation(45f); // Get the childInGroup's position in the world float childWorldPosX = ...; // This is

Game crash if interrupted while Splash Screen is on - LIBGDX

假如想象 提交于 2019-12-05 08:26:49
I have a splash screen and a menu screen class that loads all my texture atlases and skins for the menu and processes lots of stuff. If I put the constructor for the menu screen in the SplashScreen constructor or in the create() method of my main game class (MyGame class) then it would pass a lot of time with no splash screen render image on the phone while the whole stuff loads so I have delayed the loading of the menu class to the second frame render (gets called in the SplashScreen render method in the second frame); I simply check if I passed the first frame then I call a method on the

How to use Bitmap font as scene 2d actor?

牧云@^-^@ 提交于 2019-12-05 08:13:49
问题 I am developing a game using libgdx framework. How can i achieve scene2d action on bitmap font object ? so that i can write some text like score,message and run action like scene2d actor. 回答1: Take a look at the Label class, particularly the constructor that takes a CharSequence and a LabelStyle. When you initialize your LabelStyle you can supply a BitmapFont. Please note, if you'd like to scale or rotate the label you'll need to wrap it in a Container or add it to Table with setTransform()

Proper using of scene2d's Stage in a game with a huge world

人盡茶涼 提交于 2019-12-05 03:46:09
If the whole "game world" is thousands of times wider than a viewport, and if I want to use scene2d to manage game objects as Actor s, should I create Stage object as wide as the whole world, or should the Stage be some area around current viewport but not the whole world? In other words, does a Stage with greater width and height consume more memory itself, even if I render objects only on a small viewport-sized part of it? I think you misunderstood what exactly a Stage is. A Stage doesn't really have a size itself. You don't specify a width or height or the Stage , you only specify the width