Skip to content

Instantly share code, notes, and snippets.

@ekelokorpi
Created October 24, 2014 11:45
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 ekelokorpi/8aea4c7975d00967366e to your computer and use it in GitHub Desktop.
Save ekelokorpi/8aea4c7975d00967366e to your computer and use it in GitHub Desktop.
Camera: Basic usage
this.camera = new game.Camera();
this.camera.addTo(this.levelContainer);
this.camera.acceleration = 1.5;
this.camera.minX = this.camera.minY = 0;
this.camera.maxX = Math.max(0, this.level.width - game.system.width);
this.camera.maxY = Math.max(0, this.level.height - game.system.height);
this.camera.offset.x = game.system.width / 2 - 400;
this.camera.setPosition(this.player.sprite.position.x, this.player.sprite.position.y);
this.camera.follow(this.player.sprite);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment