タイトル、ボタンを 1 回押すとボールが発射され、それが終わるまで何もできなくなります。以下の発砲のための現在のコード。
public void act()
{
// Steps for calculating the launch speed and angle
ProjectileWorld myWorld = (ProjectileWorld) getWorld();
double shotStrength = myWorld.getSpeedValue();
double shotAngle = myWorld.getAngleValue();
// Checks to see if the space key is pressed, if it is, the projectile is fired
String key = Greenfoot.getKey();
if ("space".equals(key))
{
//xSpeed and ySpeed changed as requirements say
xSpeed = (int)(shotStrength*Math.cos(shotAngle));
ySpeed = -(int)(shotStrength*Math.sin(shotAngle));
actualX += xSpeed;
actualY += ySpeed;
setLocation ((int) actualX, (int) actualY);
}
現在、これにより、スペースバーを押したときにのみボールが移動するようになります。そのため、スペースバーを離して、ボールがまだ空中にある間に shotStrength と shotAngle を変更できます