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

2014/5/3

Is there a way to detect one edge of the world with atworldsedge

nc-munk nc-munk

2014/5/3

#
In my game there spawns asteroids in the top of the screen and then move though the bottom and then they reach the bottom they should be removed, but with the this code
    private void checkworldsedge()
    {
        if(atWorldEdge())
        {
            getWorld().removeObject(this);
        }
    }
they dont spawn because they already in the start they are at the edge
Zamoht Zamoht

2014/5/3

#
Change if(atWorldEdge()) to if(getY() > getWorld().getHeight() + getImage().getHeight()/2)
nc-munk nc-munk

2014/5/3

#
now they spawn agian but they dont get removed
danpost danpost

2014/5/3

#
Change line 3 to
if (atWorldEdge() && getY() > 20)
Zamoht Zamoht

2014/5/4

#
Oh thought you used a world without bounds, my bad.
nc-munk nc-munk

2014/5/4

#
thanks anyway if you have time would you take a look at another post of mine (Help Making a object break up to other objekt/images)
You need to login to post a reply.