在2d java游戏中调整玩家点击框大小的问题
因此,我试图对按下的键进行一些简单的检查,并在此基础上更改播放器的大小和形状在2d java游戏中调整玩家点击框大小的问题,java,2d,game-physics,Java,2d,Game Physics,因此,我试图对按下的键进行一些简单的检查,并在此基础上更改播放器的大小和形状hitbox(bounds.x、y、height和width) 但是,它只响应一个测试所有未按下的键,当我删除程序的该部分时,它使用默认值 public Player(Handler handler, float x, float y) { super(handler, x, y, Creature.DEFAULT_CREATURE_WIDTH, Creature.DEFAULT_CREA
hitbox(bounds.x、y、height和width)
但是,它只响应一个测试所有未按下的键,当我删除程序的该部分时,它使用默认值
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;
}
}
“然而,它只响应测试所有未按下键的部分,当我删除程序的该部分时,它使用deafault_生物值。”:哦,是的,现在我们了解了,如果没有按下键,测试部分(第二个if语句)是唯一起作用的部分,其他部分不会响应