Javascript Phaser和Web音频API-面向sprite

Javascript Phaser和Web音频API-面向sprite,javascript,audio,vector,sprite,phaser-framework,Javascript,Audio,Vector,Sprite,Phaser Framework,我试图在web音频API中使用phaser,但我不知道如何从精灵的x、y、z和旋转值转换为方向向量和上方向向量。我该怎么做 设置位置sprite.x,sprite.y,sprite.z; 设置方向0,0,0,0,0,0; ctx.setVelocity0,0,0 我很确定我已经解决了,下面是代码: function updateWithSprite(sprite) if (sprite.body) { var rot = sprite.body.rotation + M

我试图在web音频API中使用phaser,但我不知道如何从精灵的x、y、z和旋转值转换为方向向量和上方向向量。我该怎么做

设置位置sprite.x,sprite.y,sprite.z; 设置方向0,0,0,0,0,0;
ctx.setVelocity0,0,0 我很确定我已经解决了,下面是代码:

function updateWithSprite(sprite)
    if (sprite.body) {
        var rot = sprite.body.rotation + Math.PI / 2;
        this.setPosition(sprite.body.x, body.y, 0);
        this.setOrientation(Math.cos(rot), Math.sin(rot), 0);
        this.setVelocity(sprite.body.velocity.x, sprite.body.velocity.y, sprite.body.velocity.z);
    } else {
        var rot = sprite.rotation + Math.PI / 2;
        this.setPosition(sprite.x, sprite.y, 0);
        this.setOrientation(Math.cos(rot), Math.sin(rot), 0);
        this.setVelocity(0, 0, 0);
    }
}