我有一段代码创建了一个我称之为Line的对象实例。
var velLine:Line;
if(/*some conditions*/)
velLine = new Line(0, 0, x, y);
x和y取自程序中代表玩家的对象(它应该是视频游戏)。它们的类型为数字。
显示的第三行是抛出错误: 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;
}