This site requires JavaScript, please enable it in your browser!
Greenfoot back
BosniakeTyp
BosniakeTyp wrote ...

2023/12/29

setImage() errors

BosniakeTyp BosniakeTyp

2023/12/29

#
Hi, I am currently coding a SpaceInvaders clone. I am almost done and the last problem I have is with the start screen.
public void act() {
            if (sleep == 0) {
                System.out.println("Before sleepFor(30) - Setting image to SpaceMastersStartText.png");
                setLocation(getWorld().getWidth() / 2, 930);
                setImage("SpaceMastersStartText.png");
                System.out.println("00");
                sleep = 10;
                this.sleepFor(30);
            }
            if (sleep == 10) {
                System.out.println("Before sleepFor(30) - Setting image to SpaceMastersBunkerFull.png");
                setLocation(getWorld().getWidth() / 2, getWorld().getHeight() / 2);
                setImage("SpaceMastersBunkerFull.png");
                System.out.println("01");
                sleep = 0;
                this.sleepFor(30);
            }
        }
  }
Nevermind the setLocation() methods, the problem I have is that the first setImage() gets ignored, the console gives me a "00" and in the object inspector the left act cycles to sleep over are beeing shown, just ht eimage won't change
danpost danpost

2023/12/30

#
BosniakeTyp wrote...
the first setImage() gets ignored, the console gives me a "00" and in the object inspector the left act cycles to sleep over are beeing shown, just ht eimage won't change
Try "else if ..." on line 10.
You need to login to post a reply.