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

2014/9/5

Need help to left click to change world

ZahDx ZahDx

2014/9/5

#
Hey I thought It would be good to make a start menu for my game. at the moment I am wanting to make all commands more convenient. such as rather than press D to start the game, just left click.. But can't seem to get it to wrok.
    public void act() {
if (Greenfoot.isKeyDown("1")) Greenfoot.setWorld(new Help1());
if (Greenfoot.isKeyDown ("leftclick")) Greenfoot.setWorld(new Tower()); 
}
}
So in the "if (Greenfoot.isKeyDown ("leftclick")) Greenfoot.setWorld(new Tower()); " code I am wanting it to switch to the game. The D key works but I am preferring a left click.. So if you're able to help me out I would appreciate it. Thanks in advance.
danpost danpost

2014/9/5

#
I think you need to review the methods provided in the Greenfoot class documentation and choose a more appropriate method (other than 'isKeyDown').
You need to login to post a reply.