Created
July 29, 2013 01:40
-
-
Save dpeek/6101672 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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