나는 Actionscript에서 제어 할 수있는 간단한 보트를 만들고 앞으로 나아갈 수있게하고 왼쪽과 오른쪽으로 돌리지 만 돌릴 수는 없습니다. 나는 보트가 가리키는 방향으로 가길 원해.ActionScript의 간단한 보트
function moveBoat(event:Event):void
{
if(rightKeyIsDown)
{
player_mc.x += speed;
player_mc.rotationZ += speed;
}
if(leftKeyIsDown)
{
player_mc.x -= speed;
player_mc.rotationZ -= speed;
}
if(upKeyIsDown)
{
player_mc.y -= speed;
}
}
내가 뭘 잘못하고 있는지 말해 줄 수있는 사람에게 미리 감사드립니다.
편집 :
function moveBoat(event:Event):void
{
if(rightKeyIsDown)
{
player_mc.rotationZ += turnFactor;
}
if(leftKeyIsDown)
{
player_mc.rotationZ -= turnFactor;
}
if(upKeyIsDown)
{
player_mc.x += speed * Math.cos(player_mc.rotationZ * Math.PI/180);
player_mc.y -= speed * Math.sin(player_mc.rotationZ * Math.PI/180);
}
}
편집
function moveBoat(event:Event):void
{
if(rightKeyIsDown)
{
player_mc.rotation += turnFactor;
}
if(leftKeyIsDown)
{
player_mc.rotation -= turnFactor;
}
if(upKeyIsDown)
{
// convert our rotation to radians first
var rads:Number = player_mc.rotation * (Math.PI/180.0);
player_mc.x += speed * Math.cos(rads);
player_mc.y += speed * Math.sin(rads);
}
}
대신'player_mc.y - = ...'를 설정하고'player_mc.y + = ...'를 설정하면됩니다. 내 대답에서 언급 한 것처럼 ... – divillysausages