Game.cpp 673 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "Game.h"
  2. #include "Joystick.h"
  3. #include "Player.h"
  4. #include "res.h"
  5. Game::Game()
  6. {
  7. }
  8. void Game::init()
  9. {
  10. //scene layer would have size of display
  11. setSize(getRoot()->getSize());
  12. //create background
  13. spSprite sky = new Sprite;
  14. sky->setResAnim(res::ui.getResAnim("sky"));
  15. sky->attachTo(this);
  16. //create player ship
  17. _player = new Player;
  18. _player->init(this);
  19. //create virtual joystick
  20. _move = new Joystick;
  21. _move->attachTo(this);
  22. _move->setY(getHeight() - _move->getHeight());
  23. }
  24. void Game::doUpdate(const UpdateState &us)
  25. {
  26. //doUpdate is virtual method of Actor
  27. //it is being called each frame
  28. //update player each frame
  29. _player->update(us);
  30. }