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

2018/4/14

Controlling specific objects help

maboidanpost maboidanpost

2018/4/14

#
import greenfoot.*;  
public class Fighterc extends Actor
{
    public Fighterc(){
        getImage().scale(25,25);
    }
    public void act() 
    {
        rife(Fighter.lives);
    }    
    public void rife(int lives){
        int base = lives;
        if(base==1){
            if(getWorld().getObjects(Fighterc.class)!=null){
                Actor fight1 = getWorld().getObjects(Fighterc.class).get(0);
                fight1.setImage("invis.png");
            }
        }
        if(base==2){
            if(getWorld().getObjects(Fighterc.class)!=null){
                Actor fight2 = getWorld().getObjects(Fighterc.class).get(0);
                fight2.setImage("invis.png");
            }
        }       
    }
}
Works when base is 2 but not when base is 1
danpost danpost

2018/4/14

#
maboidanpost wrote...
<< Code Omitted >> Works when base is 2 but not when base is 1
You will need to show the code for the class from which the rife method is called.
You need to login to post a reply.