2d 플랫폼 작성자 Im, 스페이스 바를 길게 누르면 플레이어가 더 오랫동안 점프하려고합니다. 지금은 플레이어가 위아래로 뛰어 오를 수 있지만, 이드는 로봇 유니콘이 키를 누르고있을 때와 같은 효과를냅니다. 이 일을 어떻게 하죠? Im은 페이저 나 다른 것을 사용하지 않으며, 대부분의 튜토리얼은 그것을 사용합니다. 내 업데이트 방법에있는 것들 Heres :자바 스크립트에서 점프 스프라이트가 오랫동안 지속 되었습니까?
var gameEngine = this.game;
if (gameEngine.keyMap["Space"] && !this.jumping) { //only jump if not already in mid jump
this.jumping = true;
this.animationCurrent.elapsedTime = 0;
this.game.space = false;
}
if (this.jumping) {
if (this.animationCurrent.isDone()) {
this.animationCurrent.elapsedTime = 0;
this.jumping = false;
}
var jumpDistance = this.animationCurrent.elapsedTime/
this.animationCurrent.totalTime;
var totalHeight = 150;
if (jumpDistance > 0.5)
jumpDistance = 1 - jumpDistance;
var height = totalHeight * (-4 * (jumpDistance * jumpDistance - jumpDistance));
this.y = this.ground - height;
console.log(this.y);
}
당신은 onkeypressed를 사용하고 있습니까? 그렇다면 이것은 아마도 의도적으로 가능하지 않습니다. onkeydown을 사용하고 있습니까? 그렇다면 점프 높이를 시간의 경과에 따라 보너스로 조절할 수 있습니다. +150, +15, +5, +1. –
@TravisJ onkeydown을 사용 중입니다. – thatsnifty