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

2023/5/1

hello i am new here working on a project

jaymesww jaymesww

2023/5/1

#
i need help on my mouse curser i have a fake mouse seting its locatioon to the real one but i want it so that when i click my mouse it will click the thing below it
danpost danpost

2023/5/1

#
jaymesww wrote...
i need help on my mouse curser i have a fake mouse seting its locatioon to the real one but i want it so that when i click my mouse it will click the thing below it
Just program the actor you want the click to act on:
public void act() {
    if (Greenfoot.mouseClicked(null)) {
        MouseInfo mouse = Greenfoot.getMouseInfo();
        if (getWorld().getObjectsAt(mouse.getX(), mouse.getY(), Actor.class).contains(this)) {
            // actions as if mouse clicked this actor
        }
    }
}
jaymesww jaymesww

2023/5/2

#
thank you danpost
You need to login to post a reply.