【发布时间】:2016-03-19 12:39:51
【问题描述】:
我有一个节点“标志”数组,我想将对象的位置设置在该数组中的第一个对象上,它可以工作并且对象实际上按预期定位,但是当我进行比较时它失败并记录“不”。
设置位置的那行代码有效,但是比较失败,这是怎么回事?!
start: function () {
this.node.position = this.flags[0].position;
this.movement();
},
movement: function() {
if (this.node.position == this.flags[0].position) { // Problem
console.log("YES");
}
else {
console.log("No");
更新:
当我这样做时,它会起作用:
if (this.node.position.x == this.flags[0].position.x) // or position.y
【问题讨论】:
标签: cocos2d-x cocos2d-js