Game Development Reference
In-Depth Information
6. Add variables to store the score information and a method to update these scores
on screen:
int _player1Score;
int _player2Score;
void playerScore (int player);
7. Finally, let's add our methods:
public:
GameLayer();
virtual ~GameLayer();
virtual bool init();
static Scene* scene();
CREATE_FUNC(GameLayer);
void onTouchesBegan(const std::vector<Touch*>
&touches, Event* event);
void onTouchesMoved(const std::vector<Touch*>
&touches, Event* event);
void onTouchesEnded(const std::vector<Touch*>
&touches, Event* event);
void update (float dt);
};
#endif // __GAMELAYER_H__
There are constructor and destructor methods, then the Layer init methods, and fi-
nally the event handlers for the touch events and our loop method called update . These
touch event handlers will be added to our class to handle when users' touches begin, when
they move across the screen, and when they end.
Search WWH ::




Custom Search