mirror of
https://github.com/photonstorm/phaser
synced 2024-11-15 01:17:43 +00:00
57 lines
1.3 KiB
TypeScript
57 lines
1.3 KiB
TypeScript
/// <reference path="../../Phaser/Game.ts" />
|
|
/// <reference path="../../Plugins/CameraFX/Scanlines.ts" />
|
|
|
|
(function () {
|
|
|
|
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
|
|
|
function preload() {
|
|
|
|
game.load.image('backdrop', 'assets/pics/ninja-masters2.png');
|
|
|
|
|
|
|
|
}
|
|
|
|
var scanlines: Phaser.Plugins.CameraFX.Scanlines;
|
|
|
|
function create() {
|
|
|
|
game.world.setSize(1216, 896);
|
|
|
|
// Add our effect to the camera
|
|
scanlines = <Phaser.Plugins.CameraFX.Scanlines> game.camera.plugins.add(Phaser.Plugins.CameraFX.Scanlines);
|
|
|
|
// We'll have the scanlines spaced out every 2 pixels
|
|
scanlines.spacing = 2;
|
|
|
|
// This is the color the lines will be drawn in
|
|
scanlines.color = 'rgba(0, 0, 0, 0.8)';
|
|
|
|
game.add.sprite(0, 0, 'backdrop');
|
|
|
|
}
|
|
|
|
function update() {
|
|
|
|
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
|
{
|
|
game.camera.x -= 4;
|
|
}
|
|
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
|
{
|
|
game.camera.x += 4;
|
|
}
|
|
|
|
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
|
{
|
|
game.camera.y -= 4;
|
|
}
|
|
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
|
{
|
|
game.camera.y += 4;
|
|
}
|
|
|
|
}
|
|
|
|
})();
|