title: Unable to solve the "error: candidate is:" in cocos2dx
body: <p>I'm currently having a problem with the following error when I try to run my game. I tried to understand what the meaning of the following error but I find it hard to understand. I believe that there is more than one error but I have no clue where to look. I would love to have some help from you! </p>
  
  <pre><code>[armeabi] Compile++ thumb: MyGame_shared &lt;= BallSprite.cpp
  [armeabi] Compile++ thumb: MyGame_shared &lt;= Character.cpp
  [armeabi] StaticLibrary  : libcocos2d.a
  [armeabi] StaticLibrary  : libcocostudio.a
  [armeabi] StaticLibrary  : libcocosbuilder.a
  [armeabi] StaticLibrary  : libcocos3d.a
  jni/../../../Classes/Character.cpp:26:5: error: prototype for 'int Character::getTurnCount()' does not match any in class 'Character'
   int Character::getTurnCount()
       ^
  In file included from /Users/michael/Desktop/CocoFolder/Puzzle/cocos2d/cocos/3d/../base/CCAsyncTaskPool.h:28:0,
                   from /Users/michael/Desktop/CocoFolder/Puzzle/cocos2d/cocos/3d/../cocos2d.h:41,
                   from jni/../../../Classes/Character.h:4,
                   from jni/../../../Classes/Character.cpp:1:
  /Users/michael/Desktop/CocoFolder/Puzzle/cocos2d/cocos/3d/../platform/CCPlatformMacros.h:153:25: error: candidate is: virtual int Character::getTurnCount() const
   public: virtual varType get##funName(void) const;\
                           ^
  jni/../../../Classes/Character.h:26:5: note: in expansion of macro 'CC_PROPERTY'
       CC_PROPERTY(int, _turnCount, TurnCount); 
       ^
  jni/../../../Classes/BallSprite.cpp:62:27: error: prototype for 'BallSprite::PositionIndex BallSprite::getPositionIndex()' does not match any in class 'BallSprite'
   BallSprite::PositionIndex BallSprite::getPositionIndex()
                             ^
  In file included from /Users/michael/Desktop/CocoFolder/Puzzle/cocos2d/cocos/3d/../base/CCAsyncTaskPool.h:28:0,
                   from /Users/michael/Desktop/CocoFolder/Puzzle/cocos2d/cocos/3d/../cocos2d.h:41,
                   from jni/../../../Classes/BallSprite.h:4,
                   from jni/../../../Classes/BallSprite.cpp:1:
  /Users/michael/Desktop/CocoFolder/Puzzle/cocos2d/cocos/3d/../platform/CCPlatformMacros.h:153:25: error: candidate is: virtual BallSprite::PositionIndex BallSprite::getPositionIndex() const
   public: virtual varType get##funName(void) const;\
                           ^
  jni/../../../Classes/BallSprite.h:53:5: note: in expansion of macro 'CC_PROPERTY'
       CC_PROPERTY(PositionIndex, _positionIndex, PositionIndex); 
       ^
  make: *** [obj/local/armeabi/objs-debug/MyGame_shared/__/__/__/Classes/BallSprite.o] Error 1
  make: *** Waiting for unfinished jobs....
  make: *** [obj/local/armeabi/objs-debug/MyGame_shared/__/__/__/Classes/Character.o] Error 1
  make: Leaving directory `/Users/michael/Desktop/CocoFolder/Puzzle/proj.android-studio/app'
  Error running command, return code: 2.
  </code></pre>
  
  <p>code for the character</p>
  
  <pre><code>#include "Character.h"
  
  USING_NS_CC;
  
  Character::Character()
  : _hp(0)
  , _maxHp(0)
  , _attack(0)
  , _element(Element::None)
  , _turnCount(0)
  , _remainingTurn(0)
  {
  }
  
  Character* Character::create()
  {
      Character *pRet = new Character();
      pRet-&gt;autorelease();
  
      return pRet;
  }
  
  int Character::getTurnCount()
  {
      return _turnCount;
  }
  
  void Character::setTurnCount(int turnCount)
  {
      _turnCount = turnCount;
      _remainingTurn = _turnCount;
  }
  
  
  float Character::getHpPercentage()
  {
      return _hp * 100.f / _maxHp;
  }
  
  
  bool Character::isAttackTurn()
  { 
      _remainingTurn--;
  
      if (_remainingTurn &lt;= 0)
      { 
          _remainingTurn = _turnCount;
          return true;
      }
  
      return false;
  }
  
  int Character::getDamage(int ballCount, int chainCount, Character* attacker, Character* defender)
  {
      float baseDamage = ballCount / 3.0 * 100;
      float chainBonus = powf(1.1, chainCount - 1);
  
      float elementBonus = getElementBonus(attacker-&gt;getElement(), defender-&gt;getElement());
  
      return baseDamage * chainBonus * elementBonus;
  }
  
  float Character::getElementBonus(Element attackElement, Element defenseElement)
  {
      switch (attackElement)
      {
          case Element::Fire:
          {
  
              switch (defenseElement)
              {
                  case Element::Wind:return 2;
                  case Element::Water:return 0.5;
                  default:return 1;
              }
              break;
          }
          case Element::Water:
          {
              switch (defenseElement)
              {
                  case Element::Fire:return 2;
                  case Element::Wind:return 0.5;
                  default:return 1;
              }
              break;
          }
          case Element::Wind:
          {
              switch (defenseElement)
              {
                  case Element::Water:return 2;
                  case Element::Wind:return 0.5;
                  default:return 1;
              }
              break;
          }
          case Element::Holy:
          {
              switch (defenseElement)
              {
                  case Element::Shadow:return 2;
                  default:return 1;
              }
              break;
          }
          case Element::Shadow:
          {
              switch (defenseElement)
              {
                  case Element::Holy:return 2;
                  default:return 1;
              }
              break;
          }
          default:
          {
              return 1;
          }
      }
  }
  </code></pre>
  
  <p>Characters header</p>
  
  <pre><code>class Character : public cocos2d::Ref
  {
  public:
  
      enum class Element
      {
          Fire, 
          Water, 
          Wind, 
          Holy, 
          Shadow, 
          None, 
      };
  
  protected:
      int _remainingTurn; 
      CC_SYNTHESIZE(int, _hp, Hp); 
      CC_SYNTHESIZE(int, _maxHp, MaxHp); 
      CC_SYNTHESIZE(int, _attack, Attack); 
      CC_SYNTHESIZE(Element, _element, Element); 
      CC_PROPERTY(int, _turnCount, TurnCount);
  
  public:
      Character();
      static Character* create(); 
  
      float getHpPercentage(); 
      bool isAttackTurn(); 
      static int getDamage(int ballCount, int chainCount, Character* attacker, Character* defender); 
  
  protected:
      static float getElementBonus(Element attackElement, Element defenseElement); 
  };
  
  #endif 
  </code></pre>
  
  <p>BallSprite.cpp</p>
  
  <pre><code>#include "BallSprite.h"
  
  USING_NS_CC;
  
  BallSprite::BallSprite()
  : _removedNo(0)
  , _checkedX(false)
  , _checkedY(false)
  , _fallCount(0)
  , _positionIndex(0, 0)
  {
  }
  
  BallSprite* BallSprite::create(BallType type, bool visible)
  {
      BallSprite *pRet = new BallSprite();
      if (pRet &amp;&amp; pRet-&gt;init(type, visible))
      {
          pRet-&gt;autorelease();
          return pRet;
      }
      else
      {
          delete pRet;
          pRet = nullptr;
          return nullptr;
      }
  }
  
  bool BallSprite::init(BallType type, bool visible)
  {
      if (!Sprite::initWithFile(getBallImageFilePath(type)))
          return false;
  
      _ballType = type;
  
      setVisible(visible);
  
      return true;
  }
  
  void BallSprite::resetParams()
  {
      _removedNo = 0;
      _checkedX = false;
      _checkedY = false;
      _fallCount = 0;
  }
  
  void BallSprite::resetPosition()
  {
      setPosition(getPositionForPositionIndex(_positionIndex));
  }
  
  void BallSprite::getPositionIndex()
  { 
      return _positionIndex;
  }
  
  void BallSprite::setPositionIndex(PositionIndex positionIndex)
  {
      _positionIndex = positionIndex;
      setTag(generateTag(_positionIndex));
  }
  
  void BallSprite::setPositionIndexAndChangePosition(PositionIndex positionIndex)
  {
      setPositionIndex(positionIndex);
      resetPosition();
  }
  
  void BallSprite::removingAndFallingAnimation(int maxRemovedNo)
  {
      removingAnimation(maxRemovedNo);  
      fallingAnimation(maxRemovedNo);
  }
  
  void BallSprite::removingAnimation(int maxRemovedNo)
  {
      if (_removedNo &gt; 0)
      {
  
          auto delay1 = DelayTime::create(ONE_ACTION_TIME * (_removedNo - 1));
          auto fade = FadeTo::create(ONE_ACTION_TIME, 0);
          auto delay2 = DelayTime::create(ONE_ACTION_TIME * (maxRemovedNo - _removedNo));
          auto removeSelf = RemoveSelf::create(false); 
          runAction(Sequence::create(delay1, fade, delay2, removeSelf, nullptr));
      }
  }
  
  
  void BallSprite::fallingAnimation(int maxRemovedNo)
  {
      if (_fallCount &gt; 0)
      {
  
          setPositionIndex(PositionIndex(_positionIndex.x, _positionIndex.y - _fallCount));
  
          auto delay = DelayTime::create(ONE_ACTION_TIME * maxRemovedNo);
          auto show = Show::create();
          auto move = MoveTo::create(ONE_ACTION_TIME, getPositionForPositionIndex(getPositionIndex()));
          runAction(Sequence::create(delay, show, move, nullptr));
      }
  }
  
  std::string BallSprite::getBallImageFilePath(BallType type)
  {
      switch (type)
      {
          case BallType::Red: return "red.png";
          case BallType::Blue: return "blue.png";
          default: return "pink.png";
      }
  }
  
  
  Point BallSprite::getPositionForPositionIndex(PositionIndex positionIndex)
  {
      return Point(BALL_SIZE * (positionIndex.x - 0.5) + 1,
                   BALL_SIZE * (positionIndex.y - 0.5) + 1);
  }
  
  int BallSprite::generateTag(PositionIndex positionIndex)
  {
      return positionIndex.x * 10 + positionIndex.y;
  }
  </code></pre>
  
  <p>BallSprite header </p>
  
  <pre><code>#include "cocos2d.h"
  
  #define BALL_SIZE 106 
  #define ONE_ACTION_TIME 0.2 
  
  class BallSprite : public cocos2d::Sprite
  {
  public:
  
      enum class BallType
      {
          Blue, 
          Red, 
          Green, 
          Yellow, 
          Purple, 
          Pink, 
      };
  
      struct PositionIndex
      {
          PositionIndex()
          {
              x = 0;
              y = 0;
          }
  
  
          PositionIndex(int _x, int _y)
          {
              x = _x;
              y = _y;
          }
  
          int x; 
          int y; 
      };
  
      BallSprite();
      static BallSprite* create(BallType type, bool visible);
      virtual bool init(BallType type, bool visible); 
  
      CC_SYNTHESIZE(int, _removedNo, RemovedNo); 
      CC_SYNTHESIZE(bool, _checkedX, CheckedX); 
      CC_SYNTHESIZE(bool, _checkedY, CheckedY); 
      CC_SYNTHESIZE(int, _fallCount, FallCount); 
      CC_SYNTHESIZE_READONLY(BallType, _ballType, BallType); 
      CC_PROPERTY(PositionIndex, _positionIndex, PositionIndex); 
  
      void setPositionIndexAndChangePosition(PositionIndex positionIndex); 
      void resetParams(); 
      void resetPosition(); 
      void removingAndFallingAnimation(int maxRemovedNo); 
  
      static std::string getBallImageFilePath(BallType type); 
      static cocos2d::Point getPositionForPositionIndex(PositionIndex positionIndex); 
      static int generateTag(PositionIndex positionIndex); 
  
  protected:
      void removingAnimation(int maxRemovedNo); 
      void fallingAnimation(int maxRemovedNo); 
  };
  
  #endif
  </code></pre>