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

2014/9/17

My ammo gets stuck in the edge of the world

coder04 coder04

2014/9/17

#
Anyone no how to remove the shot/ammo when it touches something else or the edge of the world
  * the 'Act' or 'Run' button gets pressed in the environment. 
     */  
    public void act()   
    {  
       move(20.0);  
       life--;  
       eat();
       if (life == 0)
       {  
           getWorld().removeObject(this);  
    }  
    }  

    public void eat()
    {
        Actor Miniship;
        Miniship = getOneObjectAtOffset(0, 0, Miniship.class);
        if (Miniship != null)
        {
            World world;
            world = getWorld();
            world.removeObject(Miniship);
        }  
        
        Actor Warship;
        Warship = getOneObjectAtOffset(0, 0, Warship.class);
        if (Warship != null)
        {
            World world;
            world = getWorld();
            world.removeObject(Warship);
        } 
    }  
 
}  
danpost danpost

2014/9/17

#
Please do not make multiple threads for the same issue.
coder04 coder04

2014/9/17

#
sorry
You need to login to post a reply.