我是Processing编程语言的新手,目前正在尝试与我的大学团队一起制作一个基于回合制的游戏.但是我在处理函数中遇到了一个名为mousePressed的问题.问题似乎是mousePressed函数不止一次完成,即使我只按鼠标一次.我可能错了,但任何帮助都会很好.
我有5个按钮,如果我点击其中一个按钮,它会在我的ArrayList中添加X个玩家,之后它应该继续第一个玩家转向骰子,可以通过点击屏幕滚动.然而,当我点击我的添加播放器按钮时,它也会掷骰子,但我希望玩家选择数量的玩家,然后再次点击屏幕滚动骰子.
代码:
//this is my "if" the player choose to have two players, the first player turns begin
if(player.get(0) == 1){
fill(255);
text("First player turn", width/2, height/5);
noLoop();
dice.display();
dice.mouseRoll();
// here you have my dice roll function
void mouseRoll(){
if(mousePressed==true){
dice.roll(1,4); // just a random between the two number
noLoop();
Run Code Online (Sandbox Code Playgroud)