我会尽量把小游戏做成这样。我会尝试用点击代替触摸屏。从外观上看很容易,但是我找不到解决此问题的任何方法。
我想知道你是否可以帮助我。
先感谢您。
尝试这个:
set.seed(123)
y <- runif(9)
x <- runif(9)
# 1. Numbers 1-9 appear on the screen for some time
plot(x, y, pch = as.character(1:9),
xlab = "", ylab = "",
xaxt = "n", yaxt = "n",
xlim = c(-0.05, 1.05), ylim = c(-0.05, 1.05))
Sys.sleep(3)
# 2. Black boxes replace numbers and now one is allowed to click on them
for(i in 1:9) {
plot(x[i:9], y[i:9], pch = 15, cex = 3,
xlab = "", ylab = "",
xaxt = "n", yaxt = "n",
xlim = c(-0.05, 1.05), ylim = c(-0.05, 1.05))
ans <- identify(x, y, n = 1, plot = FALSE)
if(ans != i){
cat("Game over")
break
}
}