processing - How can I track where my mouse goes and then if it goes beyond 400 pixels then print "you lose"?
问题描述
When my mouse goes beyond 400 pixels, it needs to print "you lose".
I have already tried the code below. Nothing happens
void setup() {
size(800, 600);
if (mouseX > 400) {
print("game over");
}
}
Nothing happens.
解决方案
该setup()
功能只运行一次,就在程序第一次启动时。
如果您希望您的代码继续运行,请考虑将其放入draw()
函数中,该函数每秒运行 60 次。
void setup() {
size(800, 600);
}
void draw() {
if (mouseX > 400) {
print("game over");
}
}
推荐阅读
- r - 按列分组到行值
- swiftui - SwiftUI - 我的混合图像视图在 iPhone 上失败。预览中的作品
- halide - 卤化物数学是否以“浮点”(32 位)执行?
- c# - 如何为自包含控制台应用程序 Visual Studio C# 创建 .msi 安装程序
- spotfire - 如何根据日期指定的行数在 Spotfire 中显示可视化?
- reactjs - 如何在 Cypress 中访问组件道具
- javascript - 根据一个属性的唯一性过滤数组对象
- pygame - JetBrains PyCharm 找不到任何外部模块
- r - 如何添加控制线 - 不同地块不同?
- postgresql - 在postgres中将日期差异转换为真实