The
_player
object is created through a static method that uses ourblank.png
file to texture the sprite. That method also makes a call toinitPlayer
, and this is what you should type for that method:void Player::initPlayer () { this->setAnchorPoint(Vec2(0.5f, 1.0f)); this->setPosition(Vec2(_screenSize.width * 0.2f, _nextPosition.y)); _height = 228; _width = 180; this->setTextureRect(Rect(0, 0, _width, _height)); this->setColor(Color3B(255,255,255)); }
The
_player
object will have its registration point at the top of the sprite. The reason behind this top center anchor point has much more to do with the way the_player
object will be animated when floating, than with any collision logic requirements.Next comes
setFloating
:void Player::setFloating (bool value) { if (_floating == value) return; if (value && _hasFloated) return; _floating = value; ...
Cocos2d-x by Example: Beginner's Guide
By :
Cocos2d-x by Example: Beginner's Guide
By:
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
Free Chapter
Installing Cocos2d-x
You Plus C++ Plus Cocos2d-x
Your First Game – Air Hockey
Fun with Sprites – Sky Defense
On the Line – Rocket Through
Quick and Easy Sprite – Victorian Rush Hour
Adding the Looks – Victorian Rush Hour
Getting Physical – Box2D
On the Level – Eskimo
Introducing Lua!
Vector Calculations with Cocos2d-x
Pop Quiz Answers
Index
Customer Reviews