Advertisement
Guest User

Untitled

a guest
Aug 21st, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. class GameObject: public Object
  2. {
  3. public:
  4. GameObject(std::string objectName);
  5. ~GameObject(void);
  6. Component * AddComponent(std::string name);
  7. Component * AddComponent(Component componentType);
  8. Component * GetComponent (std::string TypeName);
  9. Component * GetComponent (<Component Type Here>);
  10. private:
  11. std::map<std::string,Component*> m_components;
  12.  
  13. };
  14.  
  15. GameObject * warship = new GameObject("myLovelyWarship");
  16. MeshRenderer * meshRenderer = warship->AddComponent(MeshRenderer);
  17.  
  18. MeshRenderer * meshRenderer = warship->AddComponent("MeshRenderer");
  19.  
  20. class ComponentFactory
  21. {
  22. public:
  23. static Component * CreateComponent(const std::string &compTyp)
  24. {
  25. if(compTyp == "MeshRenderer")
  26. return new MeshRenderer;
  27. if(compTyp == "Collider")
  28. return new Collider;
  29. return NULL;
  30. }
  31. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement