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

2014/4/10

Help with moving objects into the middle of the screen

kasperk22 kasperk22

2014/4/10

#
Hello guys. In my game i am trying to make objects spawn in all the sides of the screen randomly and then get them moving towards the middle of the screen. However i am not sure about two things. First thing: i have an idea about how i'll make the objects spawn all the time with delay, but i want to spawn more of them as the time goes by. So etc. in the first minute of the game, it spawns 10 objects in one minute. Then in the 10th minute, it will spawn 40 objects in one minute. Second thing: i know how to make objects move, and how to make them spawn in a random place in the sides of the screen. But what i'm not sure about, is how i make them move towards the middle. Thanks
Bowo_Ms36 Bowo_Ms36

2014/4/10

#
gamepad. java : 305
danpost danpost

2014/4/10

#
There is an Actor class method 'turnTowards'. Refer to the documentation.
kasperk22 kasperk22

2014/4/11

#
Oh, thanks danpost, i made the object move correctly.. but about the first thing.. How do i make it spawn more as the time goes by? :-)
danpost danpost

2014/4/11

#
Use an instance int field, or two, for a timer, and a minute counter. Each time the timer reaches about 3000, increment the minute counter and reset the timer back to zero. Use the minute counter to regulate the spawn rate (spawningCountPerMinute = 10+minutes*3). You can use 'if (timer%(3000/spawningCountPerMinute) == 0)' to spawn.
You need to login to post a reply.