歌曲不为按钮洗牌 - 处理 [英] Songs not shuffling for button - Processing

查看:52
本文介绍了歌曲不为按钮洗牌 - 处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个随机按钮图像,我正在使用一个实际的按钮.如果用户点击"这个图像,当前正在播放的歌曲(如果有的话)应该停止播放,并且应该播放我列表中的随机歌曲.如果没有歌曲播放,您仍然会从列表中随机播放一首歌曲.我在使用这个按钮"时遇到了麻烦,因为这首歌根本没有混洗,事实上根本没有任何反应.我已经在其他 2 个按钮上使用了相同的技术并且没有任何问题,所以我认为这可能是我调用此方法的方式,但我不确定我做错了什么.我放入了一个打印声明和洗牌...只打印一次所以我知道它有效但没有歌曲在洗牌.有谁知道我可能做错了什么?

I have a shuffle button image that I'm using an an actual button. If the user 'clicks' on this image, the current song playing (if there is one) should stop playing and a random song from my list should play. If there is no song play, you would still play a random song from the list. I'm having trouble with this 'button' because the song isn't shuffling at all, infact nothing happens at all. I've used this same technique with 2 other buttons and had no problems so I think it may be the way I'm calling this method but I'm not sure what I'm doing wrong. I put in a print statement and shuffling... only prints once so I know it works but no songs are shuffling. Does anyone know what I could be doing wrong?

//Image for shuffle button
    imageMode(CORNER);
    image(shuffle, 140, 15, 50, 50); 

void shufflePlayList() {
  current=0;
  tableau.shuffle();
}


//Shuffle button
  if(mouseX > 140 && mouseX < 190 && mouseY > 15 && mouseY < 65){ 
     println("shuffling...");
    shufflePlayList();
  }

推荐答案

条件语句只检查鼠标是否在某个区域内,不检查按钮是否被点击.因此,如果您将鼠标悬停在它上面,它将运行每一帧(前提是它在 draw 函数内)

The conditional only checks whether the mouse is within a certain area not if the button is clicked. so it will run every frame (providing it is within the draw function) if you're hovering over it

这篇关于歌曲不为按钮洗牌 - 处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆