Phaser.js tutorial
Step 6: Stop at screen edges