@royitaqi wrote:
I'm trying to inherit from Node by implementing a ctor which takes three parameters. But it seems that the ctor is not found during compilation.
Here is my
Hand.h
:#ifndef __HAND_H__ #define __HAND_H__ #include "cocos2d.h" class Hand : public cocos2d::Node { public: Hand(bool flipHorizontally, bool flipVertically, int numFingers); virtual bool init(); private: bool _flipHorizontally; bool _flipVertically; int _numFingers; cocos2d::Sprite* _sprite; private: static bool s_fingersInitialized; static cocos2d::Sprite* s_fingers[5]; }; #endif // __HAND_H__
And here is the implementation of the ctor in
Hand.cpp
:Hand::Hand(bool flipHorizontally, bool flipVertically, int numFingers) : _flipHorizontally(flipHorizontally) , _flipVertically(flipVertically) , _numFingers(numFingers) { }
And here is where I'm creating an instance of
Hand
:auto hand = new Hand(i == 0, j == 0, 1);
The compilation error message is:
jni/../../../Classes/GameBoardScene.cpp:66: error: undefined reference to 'Hand::Hand(bool, bool, int)' collect2: error: ld returned 1 exit status make: *** [obj/local/x86/libcocos2dcpp.so] Error 1
What am I doing wrong? I see some examples using a
create(...)
function instead of using a ctor. Is there a reason?
Posts: 3
Participants: 2