Manually setting object's position or have the object do it all?
Posted
by N. Lucas
on Stack Overflow
See other posts from Stack Overflow
or by N. Lucas
Published on 2010-06-11T07:39:43Z
Indexed on
2010/06/11
7:42 UTC
Read the original article
Hit count: 226
I'm stuck thinking about the best way to go about setting a line segment's position, I have a class Line(length, angle, previous) being called from a class Polygon.. Right now I have:
public function Line(length:Number, angle:Number, previous:Line = null) {
if (previous != null) {
this.x = previous.end.x;
this.y = previous.end.y;
}
/**/
}
Now, is this the best practice or should I be doing:
Polygon.addLine(length:Number, angle:Number):void {
var previous = _line[_line.length - 1]; // Array containing all Lines
var line:Line = new Line(length, angle, previous);
line.x = previous.end.x;
line.y = previous.end.y;
/**/
}
© Stack Overflow or respective owner