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

2021/2/2

How to add touch mouse command?

ShauryaThapan ShauryaThapan

2021/2/2

#
I am creating a game and I added a start button, Then I thought that if the mouse clicks to button instead of pressing enter It would be much better.
danpost danpost

2021/2/2

#
ShauryaThapan wrote...
I am creating a game and I added a start button, Then I thought that if the mouse clicks to button instead of pressing enter It would be much better.
Just add a field for the actor in your world:
1
private Actor btnStart;
In constructor:
1
2
btnStart = new Button(" Start "); // however you create it
addObject(btnStart, getWidth()/2, getHeight()/2);
In act:
1
if (Greenfoot.mouseClicked(btnStart) { // etc.
ShauryaThapan ShauryaThapan

2021/2/4

#
Thanks, works perfectly.
You need to login to post a reply.