Book Image

Cocos2d-x by Example: Beginner's Guide

By : Roger Engelbert
Book Image

Cocos2d-x by Example: Beginner's Guide

By: Roger Engelbert

Overview of this book

Table of Contents (19 chapters)
Cocos2d-x by Example Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The Player object


This represents our cyclist. It will jump, float, and collide with the _terrain object. Its x speed is passed to the _terrain object causing the Terrain object to move, side scrolling to the left of the screen.

The Player object derives, once again, from a GameSprite class. This one has getters and setters for next position, vector of movement, and the sprite's width and height.

The Player interface has inline helper methods to retrieve information about its rectangle boundaries related to its current position (left, right, top, bottom), and its next position (next_left, next_right, next_top, next_bottom). These will be used in collision detection with the _terrain object.