Im creating a simple game and i create first version with last version of cocos2d and xcode. In this part i dont have problem and the game runs ok.
But when i compile to android using “build_native.sh” the same code that works on xcode doesnt works on android, because i get exception:
Compile++ thumb : cocos2dcpp_shared <= Player.cpp
jni/…/…/Classes/entities/Player.cpp: In constructor ‘Player::Player()’:
jni/…/…/Classes/entities/Player.cpp:6:20: error: cannot call constructor ‘Player::Entity’ directly [~~fpermissive]
jni/…/…/Classes/entities/Player.cpp:6:20: error: for a function-style cast, remove the redundant ‘::Entity’
make: ***** Error 1
make: Leaving directory `/Users/paulo/Documents/workspaces/cpp/cocos2d-x/projects/flyforcoins/proj.android’
This error is because im using:
Player**player = new Player;
And Player is a class that inherit Entity that inherit CCSprite, look:
class Player : public Entity
virtual Player\ ;
class\ Entity\ :\ public\ CCSprite
\ virtualEntity ;
So the question is:
~~ How i can correct it, if i cannot use NEW in my class?
I try it too:
>Player *player = Player::create();
But i got error, because “::create” is a method from CCSprite and this method return a CCSprite that is incompatible with Player
How to solve it or what is the best metod to create custom Entity classes for games using cocos2d-x?