【发布时间】:2013-11-22 10:49:33
【问题描述】:
我不明白为什么会有差动位移Result 。 多边形和文本均匀移动,线相对误差多边形移动。
function setNewPosition(x, y) {
var lines = stage.find('Line');
if (lines.length > 0) {
lines.forEach(function inLines(line) {
var points = line.getPoints();
if (points.length > 0) {
points.forEach(function pSet(p) {
p.x += x;
p.y += y;
});
}
});
};
polygons = stage.find('Polygon');
if (polygons.length > 0) {
polygons.forEach(function inPoly(polygon) {
var points = polygon.getPoints();
if (points.length > 0) {
points.forEach(function pSet(p) {
p.x += x;
p.y += y;
});
}
});
};
texts = stage.find('Text');
if (texts.length > 0)
texts.forEach(function inText(text) {
oX = text.getX();
oY = text.getY();
text.setX(oX + x);
text.setY(oY + y);
}
);
layer.draw();
}
【问题讨论】:
-
offtopic:这段代码可以进行一些重构 ;)
标签: javascript canvas kineticjs