比方说,我有一个演员foo
和演员bar
这是foo
演员的较大版本。如何在foo
旁边显示bar
,同时轻敲foo
,然后当foo
不再被轻敲时(有点像工具提示),它会消失? Foo
位于stage2d表中。 如何在演出时演示演员的更大更完整的版本?我想要什么查看演员同时点击放大的演员的更大版本libgdx
粗略的想法:一种是我想要做什么
Actor foo = new Actor();
foo.addListener(new ActorGestureListener() {
public void touchDown (InputEvent event, float x, float y, int pointer, int button) {
// show bar next to foo (like a tooltip)
}
public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
// make bar dissapear
}
});
代码: 在这种情况下toolTipCard是我想,当我接触到的一个字符串从selectedDeck
显示演员。
Stage collectionStage;
List<String> selectedDeck;
TestCard tooltipCard;
Vector3 touch = new Vector3();
selectedDeck.addListener(new ActorGestureListener() {
public void touchDown(InputEvent event, float x, float y, int count, int button) {
if (selectedDeck.getItems().size > 0) {
tooltipCard = new TestCard(game.cardFont, cardNameToCard.get(selectedDeck.getSelected()));
tooltipCard.setWidth(Gdx.graphics.getWidth()/(7 * scale));
tooltipCard.setHeight(Gdx.graphics.getHeight()/(3.3f * scale));
touch = viewport.unproject(touch.set(Gdx.input.getX(), Gdx.input.getY(), 0));
tooltipCard.setPosition(touch.x - tooltipCard.getWidth(), touch.y - tooltipCard.getHeight());
collectionStage.addActor(tooltipCard);
}
}
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
tooltipCard.remove();
}
});
创建您自己的图像(foo),重写该图像的绘制方法并使用标志绘制条纹(纹理或标签)。 touchDown方法更改平面值。 – Aryan
获得被踢踏的演员('foo')的位置并且然后将其他演员('bar')添加到该舞台到以该被演奏的演员的大小翻译的位置('foo' ')? – Andy
不需要创建另一个actor,只有一个Actor foo,bar只是foo的一部分,就像你的Actor的数据成员一样。 – Aryan