gpt4 book ai didi

javascript - 两种Kinetic.Shape的比较

转载 作者:行者123 更新时间:2023-11-28 09:25:46 25 4
gpt4 key购买 nike

我想比较两个动力学形状:

这是我的代码:

//  -- 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);

}
}

此代码不起作用
我如何比较两个形状?

最佳答案

对于如此复杂的对象来说,这些是没有==的,你必须单独查看每个属性进行比较。

喜欢:

 shape1.getWidth() == shape2.getWidth() // will work as a comparison      
shape1.getHeight() == shape2.getHeight() // will work as a comparison
shape1.getX() == shape2.getX() // will work as a comparison
shape1.getY() == shape2.getY() // will work as a comparison
shape1 == shape2 //will not work as the objects are not the same object. Even the z-index is different.

文档中列出了所有属性以及相应的功能:http://kineticjs.com/docs/symbols/Kinetic.Node.php

关于javascript - 两种Kinetic.Shape的比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14440726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com