これらの2行からこのエラーが2回発生しています
var dx = Math.cos(deg2rad(playerRocket.rotation)) * playerThrustPower;
var dy = Math.sin(deg2rad(playerRocket.rotation)) * playerThrustPower;
私は問題を理解できないようです.私はしばらくActionscriptを使っていません.「初心者」を許してください
編集:これが私のプログラムのすべてのコードです。これまでのところ、ムービークリップは 2 つしかありません。ロケットと、マウスの左ボタンを押したままにしておくとロケットから出てくる炎だけの子ムービークリップです。
//Math Variables
var radiance:Number = 180/Math.PI;
//Keydown variables
var leftClicked = false;
//More Variables
var playerRMouseDist:Number = 0;
//player properties variables
var playerThrust = false;
stage.addEventListener(Event.ENTER_FRAME, onFrame);
stage.addEventListener(MouseEvent.MOUSE_DOWN, mousePress);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseRelease);
function onFrame(Event):void
{
movePlayerRocket();
root.scrollRect = new Rectangle(playerRocket.x - stage.stageWidth/2, playerRocket.y - stage.stageHeight/2, stage.stageWidth, stage.stageHeight);
checkPresses();
}
function mousePress(MouseEvent):void
{
leftClicked = true;
}
function mouseRelease(MouseEvent):void
{
leftClicked = false;
}
function checkPresses():void
{
if(leftClicked)
{
playerThrustOn();
}
else
{
playerThrustOff();
}
}
function playerThrustOn():void
{
playerThrust = true;
}
function playerThrustOff():void
{
playerThrust = false;
}
function getAngle(x1:Number, y1:Number, x2:Number, y2:Number):Number {
var radians:Number = Math.atan2(y2 - y1, x2 - x1);
return rad2deg(radians);
}
function getDistance(x1:Number, y1:Number, x2:Number, y2:Number):Number
{
var dx:Number = x2 - x1;
var dy:Number = y2 - y1;
return Math.sqrt(dx * dx + dy * dy);
}
function rad2deg(rad:Number):Number {
return rad * (180 / Math.PI);
}
function deg2rad(deg:Number):Number {
return deg * (Math.PI/180);
}
function movePlayerRocket():void
{
rotatePlayerRocket();
playerThrustPower();
playerRMouseDist = getDistance(mouseX,mouseY,playerRocket.x,playerRocket.y);
if(playerThrust)
{
playerRocket.playerThrustFlame.visible = true;
}
else
{
playerRocket.playerThrustFlame.visible = false;
}
var dx = Math.cos(deg2rad(playerRocket.rotation)) * playerThrustPower;
var dy = Math.sin(deg2rad(playerRocket.rotation)) * playerThrustPower;
playerRocket.x += dx;
playerRocket.y += dy;
}
function playerThrustPower():void
{
var playerThrustPower:Number = playerRMouseDist/8;
playerRocket.playerThrustFlame.width = playerThrustPower;
playerRocket.playerThrustFlame.height = playerThrustPower;
}
function rotatePlayerRocket():void
{
var walkdirection = -(Math.atan2(mouseX-playerRocket.x, mouseY-playerRocket.y))*radiance;
playerRocket.rotation = walkdirection;
}