【发布时间】:2017-12-31 13:01:59
【问题描述】:
我有这个演员 HintsWindow 包含 3 个纹理区域(背景、取消、继续)。
public class HintsWindow extends Actor {
TextureRegion bg;
TextureRegion cancel;
TextureRegion proceed;
public HintsWindow() {
bg = new TextureRegion(Gdx.files.internal("background.png"));
cancel = new TextureRegion(Gdx.files.internal("cancel.png"));
proceed = new TextureRegion(Gdx.files.internal("proceed.png"));
}
@Override
public void draw(Batch batch, float parentAlpha) {
Color color = getColor();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
batch.draw(bg, 171.031f, 484.090f);
batch.draw(cancel, 234.837f, 542.926f);
batch.draw(proceed, 407.900f, 542.926f);
}
}
绘图 TextureRegions 工作正常,但这是我的问题:
是否可以不将Listener 添加到整个actor,而是取消并继续,以便它们像按钮一样起作用?
类似的东西:
addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
// if proceed pressed --> do something
// else if cancel pressed --> addAction(Actions.fadeOut(1.0f));
}
});
【问题讨论】: