我需要帮助。我有一个播放器,我想以相同的直径顺序跳跃播放器。我想用 getHeight 和 return ( innerHeight/100 * per ) 来解决这个问题,但没有任何改进。更糟糕的是,如果画布尺寸变大,玩家不会跳得那么高,而如果窗口变小,玩家会跳得更高!我不想以硬代码方式调用。我需要响应功能!
“在投反对票之前发表评论”
r.player.force = {
x: 0,
y: -(getHeight(0.03)),
};
Matter.Body.applyForce(r.player, { x: r.player.position.x, y: r.player.position.y }, r.player.force);
public getHeight(percente: number): number {
return this.reperH() / 100 * percente;
}
this.reperH = function () {
if ((window as any).innerHeight > (window as any).innerWidth / this.aspectRatio) {
return (window as any).innerWidth / this.aspectRatio;
} else {
return (window as any).innerHeight;
}
};
完整来源:链接