0

Line と呼ぶオブジェクトのインスタンスを作成するコードがあります。

var velLine:Line;
if(/*some conditions*/)
    velLine = new Line(0, 0, x, y);

x と y は、プレーヤーを表すプログラム内のオブジェクトから取得されます (ビデオ ゲームであるはずです)。これらは Number 型です。

表示されている 3 行目は、次のエラーをスローしています: 1067: Line 型の値を無関係な型 Class に暗黙的に強制します。

これの原因は何ですか?ところで、Line コンストラクターのパラメーターはすべて Number 型です。

編集:いくつかのコード、これが役立つことを願っています

//point for the center of the player
            var pCenter:Point = new Point(p.x + 38, p.y + 38);

            //First bounds check the endpoints
            //If you're hitting an endpoint, bounce off like it's a circle
            //return false in this case so that the program doesn't trigger 2 simultaneous collisions
            var velLine:Line, perpenLine:Line;
            if(distBetweenPoints(pCenter, new Point(l.x1, l.y1))){
                velLine:Line = new Line(0, 0, p.velVector.x, p.velVector.y);
                perpenLine:Line = new Line(l.x1 - 10, l.y1 - (-1 / velLine.m) * 10, l.x1 + 10, l.y1 + (-1 / velLine.m) * 10);
                operateCollision(p, perpenLine);
                trace("hit an end point");
                return false;
            }else if(distBetweenPoints(pCenter, new Point(l.x2, l.y2))){
                velLine:Line = new Line(0, 0, p.velVector.x, p.velVector.y);
                perpenLine:Line = new Line(l.x2 - 10, l.y2 - (-1 / velLine.m) * 10, l.x2 + 10, l.y2 + (-1 / velLine.m) * 10);
                operateCollision(p, perpenLine);
                trace("hit an end point");
                return false;
            }
4

0 に答える 0