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

2020/6/1

Need help with making amount of balls appear on screen when taking the array output

Sammyy2323 Sammyy2323

2020/6/1

#
public void CreateBalls()
    {
        int [] num = new int [4];
        int Ball1 = 0;
        num [0] = Greenfoot.getRandomNumber(5-10); 
        num [1] = Greenfoot.getRandomNumber(5-10);
        num [2] = Greenfoot.getRandomNumber(5-10);
        num [3] = Greenfoot.getRandomNumber(5-10);

        for (int i= 0; i<num.length;i++) 
        {
            num[i] = Ball1;
            getWorld().addObject(Ball1, 300, 200);
        }
danpost danpost

2020/6/1

#
You cannot add an int into the world. Where are your balls? You neither create any nor use anything that resembles any type of Actor object. Also, if you are trying to create random values between 5 and 10, use "5+Greenfoot.getRandomNumber(6)".
Sammyy2323 Sammyy2323

2020/6/2

#
Ok could u maybe help figure out how I would fix this because I have been stuck for about 2 hours and in order for my game to progress, I need to finish this
You need to login to post a reply.