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

2017/6/3

Another method please???

Faheem Faheem

2017/6/3

#
I'm making a 2 player game so if u press F2 it creates player two in your world. I try to used getkey and iskeydown but both doesnt work getkey simply does nothing while iskeydown makes too many player 2's
danpost danpost

2017/6/3

#
Faheem wrote...
I'm making a 2 player game so if u press F2 it creates player two in your world. I try to used getkey and iskeydown but both doesnt work getkey simply does nothing while iskeydown makes too many player 2's
Same method -- extra condition. Use:
if (Greenfoot.isKeyDown("F2") && getObjects(Player2.class).isEmpty())
If possible, please 'Destroy' your other discussion thread post.
Faheem Faheem

2017/6/3

#
It still making multiple actors instead of just one.
danpost danpost

2017/6/3

#
Faheem wrote...
It still making multiple actors instead of just one.
Must be the way you implemented it. Please show the codes you are using.
Faheem Faheem

2017/6/3

#
If (Greenfoot.isKeyDown("F2")) { addObject(Red.class); }
danpost danpost

2017/6/3

#
Try using:
if (Greenfoot.isKeyDown("F2") && getObjects(Red.class).isEmpty())
for the first line.
You need to login to post a reply.