【发布时间】:2017-01-22 20:03:52
【问题描述】:
我正在创建一个节奏游戏。但我没有使用节拍器来计算屏幕上音符的位置(游戏界面)。我所拥有的是一个与字幕文件非常相似的带有注释映射的文件。
问题是当我透视投影笔记时,笔记显示不正确。好像我把Z轴倒了,改不了了。我想知道如何正确更改轴,因为。或者,如果有人可以帮助我解决其他问题,我将不胜感激。我尝试了不同的方法,但无法正确显示笔记。
Here is the fiddle,以及我执行透视计算的函数。
function updateNotes() {
currentPosition = (sound.seek() * 1000);
notes.forEach(function(note, index) {
var notePosition = (currentPosition * noteSpeed) - ((note.position * noteSpeed) - deadLine);
if (notePosition > offScreenY && notePosition < height) {
var ball = new Ball3d(5, '#000000');
var scale = fov / (fov + notePosition);
console.log(notePosition);
ball.x = halfWidth;
ball.y = halfHeight + notePosition * scale;
ball.scaleX = ball.scaleY = scale;
ball.draw(context);
balls.push(ball);
} else {
// elimino la nota
balls.splice(index, 1);
}
});
}
提前致谢。
【问题讨论】:
-
很难知道你想要什么。猜一猜试试
ball.y = height - notePosition * scale; -
感谢回复,我尝试的是从远方来的笔记,如下reference
标签: javascript math canvas perspectivecamera