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

2020/12/30

multiple objects appear from top to bottom

Sathya_srikanth Sathya_srikanth

2020/12/30

#
hey guys, I'm a complete Noob in greenfoot rn. How to make objects of the same actor appear and move from top to bottom of the screen? (multiple objects) (sorry for the bad English, I'm not good at speaking English)
Sathya_srikanth Sathya_srikanth

2020/12/30

#
I beg you guys, please help me!
danpost danpost

2020/12/30

#
Appearing at the same time or different times? If not same, then at regular intervals or random? and, about how often? Appearing at random locations across the top? All moving at same speeds or different down the screen? Are they to be removed or recycled when reaching bottom of screen? Is there a limit as to how many of this type actor are in the world? Show class code of actor plus attempted world code to accomplish goal (and answer above questions).
Sathya_srikanth Sathya_srikanth

2020/12/30

#
different times, random intervals..it should appear at around 1-second intervals at different locations across the top moving to the bottom, moving at the same speed, they have to be removed out from the screen, and there is only one actor that I want to do this ( monster_1). I haven't able to accomplish anything since I do not understand how to do this. thanks again!! also when the object(monster) jerry touches any of these monsters a counter should count these scores up to 50 when the world changes to another screen
Sathya_srikanth Sathya_srikanth

2020/12/30

#
sorry if im asking too much, but i have to submit this a game for the school project! again I'm so sorry if I'm giving any burden to you sir.
danpost danpost

2020/12/30

#
Sathya_srikanth wrote...
different times, random intervals..it should appear little times at different locations across the top, moving at the same speed, they have to be removed out from the screen, and there is only one actor that i want to do this ( monster_1). i haven't able to accomplish anything since i does not understand how to do this. thanks again!!
So, you want a Monster_1 class something like:
1
2
3
4
5
6
7
8
9
10
public class Moster_1 extends Actor
{
    private int speed = 3; // adjust '3' as needed
     
    public void act()
    {
        setLocation(getX(), getY()+speed);
        if (isAtEdge()) getWorld().removeObject(this);
    }
}
and in your MyWorld class:
1
2
3
4
5
6
7
8
public void act()
{
    if (Greenfoot.getRandomNumber(200) == 0) // adjust '200' as needed
    {
        int x = Greenfoot.getRandomNumber(getWidth()-50)+25;
        addObject(new Monster_1(), x, 0);
    }
}
Sathya_srikanth Sathya_srikanth

2020/12/30

#
also when the object(monster) jerry touches any of these monsters a counter should count these scores up to 50 when the world changes to another screen
danpost danpost

2020/12/30

#
Sathya_srikanth wrote...
also when the object(monster) jerry touches any of these monsters a counter should count these scores up to 50 when the world changes to another screen
Class for jerry should check for touching. Counter object should probably be in world. Place public method in world to adjust counter value and check for changing worlds.
You need to login to post a reply.