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

2014/3/24

Cant find code

FlyingGvirus FlyingGvirus

2014/3/24

#
i need code to show a message or image when my invader "win" and i looked threw all the help code they have and cant seem to find what i need
    int count =3;
    public void act() 
    {
        // Add your action code here.
        double slow = - 0.1;
        setLocation(getX() -1, getY() );
        Actor a = getOneIntersectingObject(bullet.class);
        if (a != null)
        {
        count = count -1;  
        getWorld().removeObject(a);
        }
        if (count == 0)
        {
            getWorld().removeObject(a);
            getWorld().removeObject(this);
            return;
           
        }
                if (getX() < 1)
        {
            getWorld().removeObject(this);
            Greenfoot.stop();
        }
    }    
}
i want to place it before the stop code
danpost danpost

2014/3/24

#
Just create an Actor object, give it the image you want and add it to the world.
Actor actor = new Actor(){};
actor.setImage(new GreenfootImage(" /** filename of image */ ");
getWorld().addObject(getWorld().getWidth()/2, getWorld().getHeight()/2);
FlyingGvirus FlyingGvirus

2014/3/24

#
danpost wrote...
Just create an Actor object, give it the image you want and add it to the world.
Actor actor = new Actor(){};
actor.setImage(new GreenfootImage(" /** filename of image */ ");
getWorld().addObject(getWorld().getWidth()/2, getWorld().getHeight()/2);
thanx
You need to login to post a reply.