问题标签 [scene2d]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
3923 浏览

libgdx - 在大世界的游戏中正确使用scene2d的舞台

如果整个“游戏世界”比视口宽数千倍,并且如果我想使用 scene2d 将游戏对象作为Actors 来管理,我应该创建与整个世界一样宽的 Stage 对象,还是应该Stage是当前周围的某个区域视口而不是整个世界?
换句话说,Stage具有更大宽度和高度的 a 本身是否会消耗更多内存,即使我仅在其一小部分视口大小的部分上渲染对象?

0 投票
1 回答
211 浏览

java - 为什么我的 libgdx scene2d 元素变黑了?

我将 libgdx 用于我的应用程序和皮肤有时只是消失。我没有收到任何错误,但所有 scene2d 元素在 android 上都变黑了(在桌面上它们完全消失),它们仍然可以完全正常工作,但是是黑色的(或在桌面上不可见)。我以前没有遇到过这个问题,但是现在当我开始使用 libgdx 的 AssetManager 时,它每隔三次就会发生一次。顺便说一句,当我启动应用程序时,一开始一切都很好,错误通常会在几秒钟后发生。

0 投票
1 回答
1592 浏览

java - 舞台外的 libgdx 位置窗口

我想知道如何使用 MoveToAction (或任何方法)将场景 2d 窗口定位在舞台外。我希望菜单滑入和滑出。
我的舞台和皮肤都存储在我的世界级中。

这些方法现在可以正常工作,但根本没有对其进行动画处理:

这就是我尝试更新这些功能以允许动画的方式。这里窗口已经在初始化期间添加到舞台一次,所以这些方法只处理动画。

这似乎部分起作用,因为它确实为窗口的运动设置了动画,但它停在屏幕边缘并且不会突破它。我已经尝试调整舞台的视口尺寸,但它仍然总是停在边缘。

所以问题是,我如何在舞台之外(或看似在外面)放置一个 scene2d 窗口?

0 投票
1 回答
2113 浏览

android - Is there "Hover" option to Button in libgdx?

I'm new to libgdx, I see in the constructor of Button there is a parameter for the button texture, and a texture for when it is pressed.. Here is the documentation : Scene2d.ui#Button

Is it possible to add "Hover" option to a button ?( a 3rd texture that appears when the mouse hovers over the button).

0 投票
2 回答
363 浏览

java - libgdx 在矩形内缩放/拖动

我正在使用 scene2d 进行棋盘游戏。我希望板子在屏幕的指定矩形部分内可以缩放和移动,而屏幕的其余部分保持不变。

我试图为板子使用一个单独的阶段,但还没有找到一种方法来初始化视口和相机来正确执行此操作。

我尝试了以下代码Screen.resize(int width, int height)作为测试,但是 boardStage 会垂直拉伸,并且当放大时(如这里),它会填满整个屏幕。

这样做的正确方法是什么?

0 投票
2 回答
250 浏览

java - 无法使用 Scene2D 启动活动错误

我们正在尝试使用 libGDX 中的 scene2D 绘制一些东西。我们有我们的主要活动,然后使用扩展 Android 应用程序来初始化我们的 testgame 类。这里我们定义我们的屏幕,然后在屏幕类中创建我们的舞台和演员。

问题是我们一遍又一遍地得到同样的错误:>

看一看:

更新:

这是我的清单:

0 投票
3 回答
385 浏览

java - Table not showing Image

Oh well... after almost one day trying to figure it out, couldn't find it so... here it is. I'm using scene2d.

My problem is this one, I have a class named "Tile" that extends the Image class (that extends widget) and has a texture in it of size 128x128, but when I try to add it into a table (Widget Group), my Tile disappears.

Edit: I just made a size check on the table and verified that after adding a Tile, which is 128x128 in size, inside the table, the table is showing itself with a size of 0x0... something wrong here maybe?

I already tried:

  • Using addActor() instead of add(), and the Tile shows perfectly, but can't use the table the way i need...
  • Adding other actors with add(), and they show up.
  • Adding the Tile in the middle of other actors, and what happens is that the Tile doesn't appear at all, not even as an empty space (that would happen if you add a null object to a table).
  • Seeing if there is something wrong with the Preferred size of the Tile, which is all right and happily being 128x128.

OBS: One thing that i strangely observed is that when i try to use setDrawable() in my Tile constructor (making the appropriate conversions of Texture->TextureRegion->TextureRegionDrawable), i can't have it drawn by any means, i just can make it get my texture by calling super(Texture) at the constructor, and observing the Image(Drawable) constructor, i happen to notice it does some other things when setting the drawable for the first time, BUT JUST FOR THE FIRST TIME... AND... even using super(Texture), it doesn't show when adding to a cell into a table... Maybe the problem is here? I don't know...

My questions are:

  • What is the problem?
  • If understanding the problem isn't enough to solve it, what can i do?

Edit2: As requested, here is the relevant code:

The Tile has a listener that when i mouse it over it changes its texture. I removed those listeners for testing and the error was still occurring, so... not them.

The Screen that implements the Tile (Some things are commented because i was expecting to use it like that...)

The Table is set to the middle of the screen for testing.

0 投票
1 回答
70 浏览

java - stage still receives event when visible=false?

In document ( https://code.google.com/p/libgdx/wiki/scene2d ) it states that:

If setVisible(false) is called on an actor, its draw method will not be called. It will also not receive input events.

And my code is:

where 2 table objects added commandText and currentPosition. It does not draw the objects correctly but the textfield commandText still receives the event and stores the inputs into the textfield.

Thanks.

0 投票
1 回答
1949 浏览

java - 自定义 Actor 的 Libgdx scene2d.ui InputListener 不起作用

我正在尝试使用 Libgdx Scene2dui 库并想要捕捉鼠标触地事件。我有一个自定义 Actor 和一个实例化 Actor 实例并尝试侦听触摸事件的对话框。由于某种原因,触摸事件没有被捕获。

和 Actor 实例侦听器...

知道为什么 InputListener 没有捕捉到事件吗?

我最初的想法是Actor绘制空间需要边界,所以我根据预定义的width=256和height=256添加了setBounds(),但这没有效果。

0 投票
3 回答
4181 浏览

java - 在 libgdx 中按名称获取演员

如何在 libgdx 中按名称获取演员?

我目前有以下 ChangeListener:

上面的演员是被感动的演员。一旦这个特定的演员被触摸,我需要改变另一个演员的颜色。我究竟如何才能得到那个演员的名字?