Skip to content

Instantly share code, notes, and snippets.

@jaggedsoft
Forked from photonstorm/gist:9d92f19507df7462ddd5
Last active August 29, 2015 14:11
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 jaggedsoft/7701b4fa65418b045cc4 to your computer and use it in GitHub Desktop.
Save jaggedsoft/7701b4fa65418b045cc4 to your computer and use it in GitHub Desktop.
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
function preload() {
game.load.image('ball', 'assets/sprites/shinyball.png');
}
var sprite;
function create() {
sprite = game.add.sprite(game.world.centerX, game.world.centerY, 'ball');
game.canvas.addEventListener('mousedown', requestLock);
game.input.addMoveCallback(move, this);
}
function requestLock() {
game.input.mouse.requestPointerLock();
}
function move(pointer, x, y) {
if (game.input.mouse.locked)
{
sprite.x += game.input.mouse.event.webkitMovementX;
sprite.y += game.input.mouse.event.webkitMovementY;
}
}
function update() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment