【发布时间】:2021-06-06 01:14:22
【问题描述】:
我正在使用 TiledMap 编写一个简单的 Libgdx 游戏。我正在尝试创建一个压力板,当玩家角色踩到它时,它只会切换一次“激活”布尔值。目前,我正在绘制压力板的渲染函数中,布尔值不断切换。
我假设这相对简单,只是我无法理解它。
下面是 PressurePlate 类:
public class PressurePlate extends GameTrigger {
private boolean activation; // whether the pressure plate is "on" or "off"
public PressurePlate (Texture img, Vector2 initialPos) {
super ("PressurePlate", initialPos, img, true);
}
public boolean isCurrentlyUsed (ArrayList <Entity> entities) {
for (Entity e : entities)
{
if (e.getIntPositionX() == this.getIntPositionX() && e.getIntPositionY() == this.getIntPositionY())
{
return true;
}
}
return false;
}
public boolean isActivated () {
return this.activation;
}
public void setIsActivated (boolean isActivated) {
this.activation = isActivated;
}
}
谢谢!
【问题讨论】:
标签: loops libgdx boolean-logic tiled