Created
December 14, 2018 20:08
-
-
Save sovietspy2/0e1c63c4ff919ca763a771eda66f7514 to your computer and use it in GitHub Desktop.
plugins
This file contains 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
// https://labs.phaser.io/edit.html?src=src\plugins\add%20scene%20plugin%20in%20config.js | |
var config = { | |
type: Phaser.AUTO, | |
parent: 'phaser-example', | |
width: 800, | |
height: 600, | |
scene: { | |
preload: preload, | |
create: create, | |
update: update | |
} | |
}; | |
var game = new Phaser.Game(config); | |
function preload () | |
{ | |
console.log("LOADING PLUGIN"); | |
this.load.scenePlugin({ | |
key: 'BannerTextPlugin', | |
url: 'assets/loader-tests/BannerTextPlugin.js', | |
sceneKey: 'banner' | |
}); | |
this.load.text('3x5', 'assets/loader-tests/3x5.flf'); | |
this.load.spritesheet('balls', 'assets/sprites/balls.png', { frameWidth: 17, frameHeight: 17 }); | |
this.load.spritesheet('tiles', 'assets/tilemaps/tiles/drawtiles.png', { frameWidth: 32, frameHeight: 32 }); | |
this.load.image('chunk', 'assets/sprites/chunk.png'); | |
} | |
function create () | |
{ | |
const { LEFT, RIGHT, UP, W, A, D , SPACE, R} = Phaser.Input.Keyboard.KeyCodes; | |
this.keys = this.input.keyboard.addKeys({ | |
left: LEFT, | |
right: RIGHT, | |
up: UP, | |
w: W, | |
a: A, | |
d: D, | |
space: SPACE, | |
r: R | |
}); | |
this.banner.config('3x5'); | |
this.banner.createText('Phaser 3', 0, 32, 'balls', 1); | |
this.banner.createText('Brings you a new Banner Text Plugin', 0, 140, 'chunk'); | |
this.banner.createText('PHASER', 0, 300, 'tiles', 5); | |
} | |
function update() { | |
if (this.keys.r.isDown) { | |
console.log("restarted"); | |
this.scene.restart(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment