0

我有一段代码创建了一个我称之为 Line 的对象的实例。

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

x 和 y 取自程序中代表玩家的对象(它应该是视频游戏)。它们是 Number 类型。

显示的第三行抛出错误: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