April 2017
Beginner to intermediate
394 pages
9h 16m
English
In order to use the Component Object Model, first create a game object, then add some components, then finally add it to the M5ObjectManager which calls an update on the game object every frame. Let's look at some code for creating objects and components.
If we wanted to create a Player object to fly around on screen, but stay within the bounds of the screen, we could do this inside the Init method of a stage:
M5Object* pObj = new M5Object(AT_Player); GfxComponent* pGfxComp = new GfxComponent; PlayerInputComponent* pInput = new PlayerInputComponent; ClampComponent* pClamp = new ClampComponent; pObj->AddComponent(pGfxComp); pObj->AddComponent(pInput); pObj->AddComponent(pClamp ); //Set position, ...
Read now
Unlock full access