当我使用拼接功能时,它会插入点,但会复制数组最后一个元素的副本。
for(indexpoint=0;indexpoint<intpoints.length;indexpoint++)
{
temp.points[indexpoint].x = intpoints[indexpoint].x+this.x;
temp.points[indexpoint].y = intpoints[indexpoint].y+this.y;
}
const point:Point = new Point();
point.x = (intpoints[2].x+intpoints[3].x)/2+this.x;
point.y = (intpoints[2].y+intpoints[3].y)/2+this.y;
temp.points.splice(3,0, point);
答案 0 :(得分:1)
这不应该发生。
我试过了:
var a:Array = new Array(new Point(0,0), new Point(0, 1), new Point(0, 2));
var p:Point = new Point(0, 3);
a.splice(3, 0, p);
trace(a);
这正确追踪:(x = 0,y = 0),(x = 0,y = 1),(x = 0,y = 2),(x = 0,y = 3)
您可以在调用splice之前尝试跟踪temp.points数组吗?