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

2021/2/20

Set image from another actor void act()

alex_denis20011 alex_denis20011

2021/2/20

#
Hello I have a problem. I want to set a new image for an actor in another actors void act(). More specifically I want to change the health when actor is shooted, So I have to set the new image of the health bar inside the void act of the enemy. Any help would be much appreciated.
alex_denis20011 alex_denis20011

2021/2/20

#
i tried this 2 codes lines as well,none of them seemed to work
if(Viata==0)
        {
            getWorld().removeObject(this);
            if (viata4.getWorld() != null)
                getWorld().removeObject(viata4);
        }
and also
if(Viata==0)    setImage(new GreenfootImage("poza2.png"));
danpost danpost

2021/2/20

#
Not sure what you actually want. Quite vague in describing. Plus, the two code sets do different things. Try for line 5:
viata4.getWorld().removeObject(viata40;
or for second try:
if (Viata == 0) viata4.setImage(new GreenfootImage("poza2.png");
alex_denis20011 alex_denis20011

2021/2/20

#
Thank you Dan,I m grateful for this,sorry that i'm vague.
You need to login to post a reply.