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

2017/1/11

Change image problem

rkr rkr

2017/1/11

#
When my image changes to host.png it does not show the image for some reason. But when it changes to nail.png it does. Is this a glitch?
    public void invincible(){
        //List<Hero> h = getObjectsInRange(200,Hero.class);
        timer--;
        if (timer == 499){
            setImage(Images.imgs.get("host.png"));
        }
        if  (timer > 430){
            checkDeath();
        }
        if (timer ==430){
            shoot();
        }
        if (timer == 400){
            setImage(Images.imgs.get("Nail.png"));
            change = false;
        }
        if (timer == 0){
            timer = 500;
        }
    }
Nosson1459 Nosson1459

2017/1/11

#
Are there errors in the terminal window? If yes what does it say? If not then you have to make sure everything is OK with the image "host.png".
rkr rkr

2017/1/11

#
nothing pops up in the terminal window and the picture is ok
rkr rkr

2017/1/11

#
i tried a different pic in its place but it still dosent show
danpost danpost

2017/1/11

#
Are you sure the imgs array has the exact same name that is being asked for -- "host.png"? (case-sensitivity question) You could try just setting the image right there using:
setImage("host.png");
If that works, then the problem is somehow related to the array.
You need to login to post a reply.