所以,我试图对正在按下的键进行一些简单的检查,并根据我将改变玩家hitbox (bounds.x,y,height,and width)
的大小和形状。
然而,它仅响应测试未按下所有键的那个,当我删除该部分程序时,它使用default_creature
值。
public Player(Handler handler, float x, float y) {
super(handler, x, y, Creature.DEFAULT_CREATURE_WIDTH,
Creature.DEFAULT_CREATURE_HEIGHT);
if (handler.getKeyManager().left || handler.getKeyManager().right) {
bounds.x = 0;
bounds.y = 32;
bounds.width = 60;
bounds.height = 28;
}
if (!handler.getKeyManager().downtrue && !
handler.getKeyManager().up && !handler.getKeyManager().left
&& !handler.getKeyManager().right) {
bounds.x = 16;
bounds.y = 32;
bounds.width = 32;
bounds.height = 28;
}
if (handler.getKeyManager().downtrue) {
bounds.x = 0;
bounds.y = 32;
bounds.width = 60;
bounds.height = 28;
}
}