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

2021/7/22

Greenfoot.mouseClicked(this) remove object.

StndRed StndRed

2021/7/22

#
Hello, I'm having issues with removing an image using this code:
public class Dragsup extends Actor
{
    public Dragsup()
    {
        setImage(new GreenfootImage("Eres un milagro del universo, \n un regalo de Dios. ", 48, Color.WHITE, Color.BLACK));
        }  
    public void act()
    {        
            if (Greenfoot.mouseClicked(this))
        {
             getWorld().removeObject(this);
        } 
    }
}
Now to make sure it wasn't the code, i applied the if greenfoot.mousclicked this, get world remove object on another actor and it was removed. Any help would be greatly appreciated.
Super_Hippo Super_Hippo

2021/7/22

#
Maybe there is another actor (even a transparent part of its image) in front of the actor?
StndRed StndRed

2021/7/22

#
How would one check to see if there is another actor in front of this?
danpost danpost

2021/7/23

#
StndRed wrote...
How would one check to see if there is another actor in front of this?
Just make sure this one is on top. Add the following line to your world constructor:
setPaintOrder(Dragsup.class);
StndRed StndRed

2021/7/23

#
Danpost you da man. Thank you ill give that a shot.
StndRed StndRed

2021/7/23

#
Works like a charm. Thank you
You need to login to post a reply.