我有两个布尔变量var lookingLeft = false
和var lookingRight = false
一个椭圆ellipse(40, 40, i, i)
。
var lookingLeft = false;
var lookingRight = false;
function draw() {
let i = 30;
ellipse(40, 40, i, i);
if (nose.x > leftEye.x) {
lookingLeft = true;
}
if (nose.x > rightEye.x) {
lookingRight = true;
}
if (lookingLeft === true) {
i = i + 10 //this is not working
rect(10, 10, 50, 50); //but this is
}
if (lookingRight === true) {
i = i - 10 //again, this is not working
rect(300, 300, 50, 50); //but this is
}
}
我想i
增加 10 时lookingLeft = true
减少 10 时lookingRight = true
。
这是我的 p5 网络编辑器草图:https ://editor.p5js.org/saskiasmith/sketches/7WMDPGPbrc
非常感谢!