Skip to content

Instantly share code, notes, and snippets.

@dpeek
Created July 29, 2013 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpeek/6101672 to your computer and use it in GitHub Desktop.
Save dpeek/6101672 to your computer and use it in GitHub Desktop.
class GameScene extends Scene {
// ...
public override function update() {
// Keep camera.x centered on the player
HXP.camera.x = player.x - HXP.halfWidth + 64;
// Keep camera.y centered on the player,
// unless it would show below the map.
// In that case, keep to the bottom fo the map.
if (HXP.camera.y + HXP.height >= map.map.fullHeight) {
HXP.camera.y = HXP.halfHeight + 64;
} else {
HXP.camera.y = player.y - HXP.halfHeight + 64;
}
super.update();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment