【发布时间】:2017-06-24 11:00:28
【问题描述】:
我正在创建一个包含多个参与者的Table。该表还包含一个附加了 ClickListener 的图像。当其他演员被点击或点击时,我会绘制一个箭头,该箭头可以定位表格中的图像。我想知道箭头何时进入和退出表格中的图像。问题是输入事件并不总是触发,或者它仅从图像的一部分触发,或者一旦触发输入,就会触发退出。
知道有什么问题吗?
oponentHand = new Table();
for (int i = 0; i < 4; i++) {
oponentHand.add().width(game.developingWidth / (11.5f)).height(game.developingHeight / (5.5f)).padLeft(5)
.expand();
}
Texture oponentTexture = new Texture(Gdx.files.internal("data/mihai.jpg"));
Table tempTable = new Table();
oponentPortrait = new Image(oponentTexture);
oponentLife = new Label("Life", textsStyle);
tempTable.add(oponentLife).row();
oponentPortrait.setTouchable(Touchable.enabled);
tempTable.add(oponentPortrait).expand().fill();
oponentPortrait.addListener(new ClickListener() {
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
super.enter(event, x, y, pointer, fromActor);
isOnTarget = true;
targetedCardType = "enemyHero";
System.out.println("Entering enemy hero");
}
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
super.exit(event, y, y, pointer, toActor);
if (pointer == -1) {
isOnTarget = false;
System.out.println("Exiting enemy hero");
}
}
});
Texture oponentPowerTexture1 = new Texture(Gdx.files.internal("data/powSword.png"));
Texture oponentPowerTexture2 = new Texture(Gdx.files.internal("data/powShield.png"));
Image firstOponentPower = new Image(oponentPowerTexture1);
Image secondOponentPower = new Image(oponentPowerTexture2);
oponentHand.add(firstOponentPower).width(game.developingWidth / (11.5f)).height(game.developingHeight / (6))
.padLeft(5);
oponentHand.add(tempTable).width(game.developingWidth / (11.5f)).height(game.developingHeight / (6)).fill().padLeft(5);
oponentHand.add(secondOponentPower).width(game.developingWidth / (11.5f)).height(game.developingHeight / (6))
.padLeft(5);
for (int i = 0; i < 4; i++) {
oponentHand.add().width(game.developingWidth / (11.5f)).height(game.developingHeight / (6)).padLeft(5)
.expand();
}
【问题讨论】:
标签: libgdx scene2d clicklistener