c++cocos2d-xcocos2d-x-3.0ccnode

cocos2d-x 3.0rc0 for android in ubuntu: how to compare two CCNodes


In the current cocos2d-x 3.0rc0 distribution, the method "isEqual" doesn't seem to be available for CCNode. Using

node1->isEqual(node2)

I get an error saying "error: 'cocos2d::CCNode' has no member named 'isEqual'" )

How can I compare two nodes then?

Thanks.


Solution

  • If pointer equality suffices:

    if (node1 == node2) { .. }
    

    Otherwise you'd have to implement an equality test function that does a member-by-member comparison, at least for those that you consider important for an equality test.