I don´t really like to guess to use a blind development way to follow… so i ask you more experienced programmers…
Do you use Composing or Inheritance in your development?..
I have done my first two scenes (Menu and a simple non playable comic view prologue story)…
The third scene is the first gameplay so of course need to create my player.
But a player could be a simple sprite that reacts to input, that does not requires an external custom type, say Player.h, this is the way you follow or do you create your own Player.h class with jump, crouch, run and talk member functions?..
I create custom nodes for almost everything unless it literally only is using the variables and functions of the base cocos node I would subclass from.
That being said, Some subclasses can be compositions with others:
Ex:
class BaseSpaceShip: public Sprite class HeroShip1: public BaseSpaceShip class HeroShip2: public BaseSpaceShip class Shadow: public Sprite
The BaseSpaceShip class could contain 1 or more of the Shadow class inside it etc which now are also inherited by the more customized spaceship subclasses.
Of course! How did not get it?
My player can inherit from sprite class
This should be my inheritance so…
ControllableType : public Sprite
VehicleType : public ControllableType
HumanType : public ControllableType
Starship : public VehicleType
Henry : public HumanType
John : public HumanType
For scenes i was thinking something like this:
ScnMaster : public Scene
ScnUIType : public ScnMaster
ScnGamePlayType : public ScnMaster
ScnMainMenu : public ScnUIType
ScnForest : public ScnGamePlayType
May be?
Thanks
Edit: And I could say it should be a good idea to use Singleton for save/load and store player stats isn’t ?
Yes, I generally make singletons for all my high level processes.
ex:
DatabaseManager
ChatCache
UIState
…
And yes on subclassing the cocos Sprite class, generally, look for the cocos node that at base has what you need (assuming you need some cocos attributes for the class), and build on top. ie, you can use the Ref class if you need an automatic reference count on some basic data classes. You can use Node if you need something generic for adding to the node hierarchy, you can use Sprite if the node will be a sprite at its base, Layer …, Scene …, Renderer, etc etc