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

2015/11/12

Actors (balls) fall down

IsabelSchouten IsabelSchouten

2015/11/12

#
Hi everyone! We have a code for actors which fall down, i will place the code downhere. The problem is that we also need a code, the 'while' code, for more actors than the 'bal' actors, because we have more different balls that need to fall down. These actors are called 'one' and 'two' etc. So our question is, how do we write a code for these actors
//fall down
            while (!isTouching(Bal.class) && getY() < getWorld().getHeight() - 1) 
            {
                setLocation(getX(), getY()+1);
            }
            setLocation(getX(), getY()-1);
            active = false;
            ((SpeelVeld) getWorld()).spawnNewBal();
            
?
Super_Hippo Super_Hippo

2015/11/12

#
You don't write code for 'actors', you write code for 'classes'. So you could just create another instance of the class.
You need to login to post a reply.