首页 > 解决方案 > 如何防止元素在 p5 中穿过我的墙壁?

问题描述

我使用 ml5 -posenet 进行了面部跟踪交互。现在我希望跟踪粒子留在特定区域。所以我建立了一个边界。不知何故,它仍在运行。但它显示在控制台中,检测到碰撞,我已经将声音作为一个事件放在它上面,所以碰撞本身似乎不是问题。

 if(noseX> rect1X -rect1Width  && 
 noseX < rect1X + rect1Width &&
 noseY > rect1Y- rect1Height &&
 noseY < rect1Y + rect1Height) {
 mySound.play();

console.log('nose collided with blue');
noseXchange*= -1;
noseYchange*= -1;

标签: javascriptp5.jsboundary

解决方案


推荐阅读