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

2020/4/16

Making one new bird object when an existing bird object touches bottom of world

BigBoy123 BigBoy123

2020/4/16

#
When a bird touches the bottom of the world I make it stop moving and want to add one new bird. With my code it adds a bunch of birds when I just want one. if (getY()>=getWorld().getHeight() -1) { xSpeed=0; ySpeed=0; world.addObject(new Bird(5,0), Greenfoot.getRandomNumber(800), Greenfoot.getRandomNumber(600)); }
danpost danpost

2020/4/16

#
Without seeing the rest of the class, I would guess (possibly wrongly) that a second condition to spawn a new Bird object might be: ySpeed > 0
Dr.Blythe Dr.Blythe

2020/4/19

#
*ahem*, really?
You need to login to post a reply.