1
玩家跳躍,但不會回落,如果您按住向上箭頭鍵,玩家會飛/浮動,我該如何解決這個問題,以便玩家退回下?如果提供源代碼會很好,但任何幫助都很好。Greenfoot:跳躍和回落不起作用
import greenfoot.*;
public class Character extends Actor
{
double Force = 0;
double Gravity = 0.5;
double Boost_Speed = -6;
int Wait = 0;
public void act()
{
setLocation(getX(), (int)(getY() + Force));
if(Greenfoot.isKeyDown("up")){
Wait++;
Force = Boost_Speed;
if(Wait >= 8)
{
setLocation(getX(), (int)(getY() + 1));
Wait = 0;
}
}
Force = Force + Gravity;
}
}
出於好奇...爲什麼你調用'setLocation'兩次嗎? – byxor