METS BLOG

METS BLOG

Cocos2D-X Platformer tutorial Part 3 – Movement

Time to get on with some movement, for now we will focus on moving only left and right, check out the updateScene method.

  • Here we are listening for pressed keyboard events, so something should change when they are pressed, similarly touch and mouse events can be handled(I’ll do it sometime later)
  • What does velocity do anyway? Well when LEFT/RIGHT is pressed player’s velocity is set to max, which simply means the player’s moving, when velocity is 0 player’s just standing, notice the velocity is being added to players position
  • Clamping? That’s to keep the player from accelerating indefinitely or see if he has stopped
  • What about Damping? this is where the velocity decreases, but don’t forget if the key is still being pressed, the next frame velocity will be at maximum again so we continue to walk
  • I wanna jump! yea that’s for part 5, make sure you understand whats going on here, its actually the same logic but there should be a constant force applied to simulate gravity, besides I think super koalios gravity needs some adjustments


2 responses to “Cocos2D-X Platformer tutorial Part 3 – Movement”

  1. quickfingers says:

    I am following the tutorials. I already define RIGHT_ARROW and LEFT_ARROW in globals.h and included it for some reason there is an error. IntelliSense: identifier “RIGHT_ARROW” is undefined same for LEFT_ARROW. Any idea why that is?

  2. quickfingers says:

    Actually, never mind I got it.

Leave a Reply

Your email address will not be published. Required fields are marked *