【问题标题】:How to clear the status text of a Java applet?如何清除 Java 小程序的状态文本?
【发布时间】:2016-02-29 16:06:34
【问题描述】:

我正在使用一个小程序在 Java 中对游戏 Breakout 进行编程,并且我在小程序的窗口中使用了一些 showStatus("") 行来说明一些事情。

但是当我开始一个新游戏时,我希望状态文本消失。也就是说,当按下某个键并发生某些操作时。如果按下向上箭头(键 1004),则游戏开始,我希望状态文本消失。

我怎样才能做到这一点?

这是我目前的解决方案:

public boolean keyDown(Event e, int key) {
    if(key==1004 && ballready) {
        ballready = false;
        ball.xchange = BallSpeedX;
        ball.ychange = BallSpeedY;
    }
    if(key==1006)
        leftArrow = true;
    if(key==1007)
        rightArrow = true;
    return true;
}

【问题讨论】:

    标签: java applet status


    【解决方案1】:

    答案很简单!只需逐字添加 showStatus(" ")。

      public boolean keyDown(Event e, int key) {
        if(key==1004 && ballready) {
            ballready = false;
            ball.xchange = BallSpeedX;
            ball.ychange = BallSpeedY;
            showStatus(" ")
        }
        if(key==1006)
            leftArrow = true;
        if(key==1007)
            rightArrow = true;
        return true;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-07
      • 2016-12-12
      • 2015-12-01
      • 2012-04-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多