Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Cocos2d-X Game Development Blueprints

You're reading from   Cocos2d-X Game Development Blueprints Build a plethora of games for various genres using one of the most powerful game engines, Cocos2d-x

Arrow left icon
Product type Paperback
Published in Jul 2015
Publisher Packt
ISBN-13 9781783985265
Length 392 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Karan Sequeira Karan Sequeira
Author Profile Icon Karan Sequeira
Karan Sequeira
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. A Colorful Start FREE CHAPTER 2. How to Fly a Dragon! 3. Not Just a Space Game 4. Back to the Drawing Board 5. Let's Get Physical! 6. Creativity with Textures 7. Old is Gold! 8. Box2D Meets RUBE 9. The Two Towers 10. Cross-platform Building Index

Collisions with moving platforms and enemies


If you think about implementing moving platforms, it might seem a bit tricky at first—considering how characters standing right on top of them are supposed to move along with them. We don't have a concept of friction here since there is no physics engine. Also, moving platforms cannot be represented simply by tiles since they have to move smoothly across the screen. If they were represented by tiles, they would jump from one column to the next while moving horizontally. Thus, we will represent a moving platform simply as an axis aligned bounding box.

One thing worth observing is in the UpdateSpeed function of class Hero. Right after we've added gravity, we check whether the hero is standing on a platform and act accordingly. It is imperative that this happens before we add any subsequent forces based on user input. Failing to do so will cause the hero to be stuck on the platform irrespective of user input as we are manually setting the AABB's position...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image