【发布时间】:2013-01-04 15:08:30
【问题描述】:
我想在两个动力学形状之间进行比较:
这是我的代码:
// -- self.group = Kinetic.Group() With 10 Shapes
//New Group
var Ngroup = new Kinetic.Group();
//ss New Shape
var ss = new Kinetic.Shape();
//Insert Current Shape Into ss
ss = getShape(t);
// Checking If current shape exist in self.group
for(var s in self.group) {
//Check If s = ss <---
if(ss == s){
//Add The Shape to new group
alert("Found");
Ngroup.add(ss);
} else {
//Add the Old Shape to the new group
Ngroup.add(s);
}
}
此代码无效
如何比较两个形状?
【问题讨论】:
-
我认为你必须弄清楚两个“Shape”对象的“==”是什么意思。如果它们的大小相同,红色三角形 == 到蓝色三角形吗?如果他们处于不同的位置怎么办?
-
如何获取形状位置?
-
我认为父类(“节点”)上有一个 API。我只是browsing the documentation;我不是图书馆方面的专家。
-
嗯,API 文档有点少。有一个“getPosition()”函数,但没有描述返回值。
标签: javascript html canvas kineticjs