Processing Kinect-游戏与娱乐;在处理过程中暂停音乐
当我向前移动我的手时,我尝试播放音乐,当我移动我的手背景时,暂停音乐,如图所示 我可以在前进时播放音乐。但当我移动背景时,我看不到如何暂停播放器Processing Kinect-游戏与娱乐;在处理过程中暂停音乐,processing,kinect,minim,simple-openni,Processing,Kinect,Minim,Simple Openni,当我向前移动我的手时,我尝试播放音乐,当我移动我的手背景时,暂停音乐,如图所示 我可以在前进时播放音乐。但当我移动背景时,我看不到如何暂停播放器 import ddf.minim.*; import SimpleOpenNI.*; SimpleOpenNI kinect; int closestValue; int closestX; int closestY; PImage img; AudioPlayer player; Minim minim; void setup() {
import ddf.minim.*;
import SimpleOpenNI.*;
SimpleOpenNI kinect;
int closestValue;
int closestX;
int closestY;
PImage img;
AudioPlayer player;
Minim minim;
void setup() {
size(640, 480);
img = loadImage("background.jpg");
kinect = new SimpleOpenNI(this);
kinect.enableDepth();
image(img, 0, 0);
minim = new Minim(this);
player = minim.loadFile("music.mp3");
}
void draw() {
closestValue = 600;
kinect.update();
int[] depthValues = kinect.depthMap();
// this breaks our array down into rows
for (int y = 0; y < 480; y++ ) {
// this breaks our array down into specific pixels in each row
for (int x = 0; x < 640; x++) {
// this pulls out the specific array position
int i = x + y * 640;
int current = depthValues[i];
//now we're on to comparing them!
if ( current > 0 && current < closestValue) {
closestValue = current;
closestX = x;
closestY = y;
player.play();
}
/// I made this else if in order to make the pause when the current value is superior or equal to the closest value ///
/// but it doesn't play the player, it seems that it directly pauses the player. ///
/*else if ( current > 0 && current >= closestValue) {
player.pause();
}*/
}
}
// draw the depth image on the screen
image(kinect.depthImage(), 0, 0);
// draw that swanky red circle identifying it
fill(255, 0, 0); //This sets the colour to red
ellipse(closestX, closestY, 25, 25);
}
导入ddf.minim.*;
导入SimplePenni。*;
simplepenni-kinect;
int最接近值;
int closestX;
密室;
皮马杰;
音频播放器;
极小极小;
无效设置(){
尺寸(640480);
img=loadImage(“background.jpg”);
kinect=新的SimplePenni(本);
kinect.enableDepth();
图像(img,0,0);
最小值=新的最小值(本);
player=mini.loadFile(“music.mp3”);
}
作废提款(){
最接近值=600;
kinect.update();
int[]depthValues=kinect.depthMap();
//这会将数组分解为行
对于(int y=0;y<480;y++){
//这会将数组分解为每行中的特定像素
对于(intx=0;x<640;x++){
//这将拉出特定的阵列位置
int i=x+y*640;
int current=深度值[i];
//现在我们开始比较它们!
如果(当前>0&¤t0&¤t>=closestValue){
player.pause();
}*/
}
}
//在屏幕上绘制深度图像
图像(kinect.depthImage(),0,0);
//画一个时髦的红色圆圈来标识它
填充(255,0,0);//这将颜色设置为红色
椭圆(closestX,closestY,25,25);
}
尝试播放。暂停();在播放代码段中,查看发生了什么。如果它暂停。这是因为您用于else-if语句的表达式