我正在制作类似Flappy Bird的游戏。单击浏览器窗口时,该字符应向上移动,但我的代码不起作用。以下是相关的代码行:
var dudeYSpeed = 0;
var dudeXSpeed = 0;
var dudeJumping = false;
var jumpSpeed = -3;
if (mouseDown && dudeJumping === false){
dudeJumping = true;
dudeYSpeed = jumpSpeed;
}
else {
translateY += dudeYSpeed;
dudeYSpeed += gravity;
dudeJumping = false;
}
translateX += dudeXSpeed;
答案 0 :(得分:0)
如果translateY
为真,您只会更新dudeYSpeed
和dudeJumping
。无论输入是什么,您都应该在每一帧中更新这些变量。