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

2012/10/25

PROBLEM!

popiroprios popiroprios

2012/10/25

#
I want to introduce two actors from the world, appearing in the center of the world and be falling.
public class MONDO extends World
{
int tiempo= 0;
int n=0;    
    public MONDO()
    {    
        tiempo ++;
        if (tiempo==50)
        {
            int n=Greenfoot.getRandonNumber.getWidth()-20;
            switch ( Greenfoot.getRandomNumber(2) )
            {
            case 1: while 
            
            addObject(new MON1(), n, getHeight()-20);
               
            case 2: while 
            
            addObject(new MON2(),n, getHeght()-20);
        }
            
            tiempo=0
            
    }
}
}
danpost danpost

2012/10/25

#
Looks like you need help on several fronts, but, in this case, mainly your 'switch' block. Actually, the block is set up properly, however, what you are doing inside puzzles me. You probably should remove the 'while's and you probably want to add a 'break;' after each addObject method call. I think you want the following for line 10
int n = Greenfoot.getRandomNumber(getWidth() - 20);
Also, you can remove line 4.
You need to login to post a reply.