Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update custom sprite class ES6 example to use ES6 format #351

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions public/src/game objects/sprites/custom sprite class ES6.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,26 @@ class Brain extends Phaser.GameObjects.Sprite {

}

var config = {
type: Phaser.AUTO,
parent: 'phaser-example',
scene: {
preload: preload,
create: create
class Example extends Phaser.Scene
{
preload ()
{
this.load.image('brain', 'assets/sprites/brain.png');
}
};

var game = new Phaser.Game(config);
create ()
{
this.add.existing(new Brain(this, 264, 250));
this.add.existing(new Brain(this, 464, 350));
this.add.existing(new Brain(this, 664, 450));
}

function preload ()
{
this.load.image('brain', 'assets/sprites/brain.png');
}

function create ()
{
this.add.existing(new Brain(this, 264, 250));
this.add.existing(new Brain(this, 464, 350));
this.add.existing(new Brain(this, 664, 450));
}
const config = {
type: Phaser.AUTO,
parent: 'phaser-example',
scene: [ Example ]
};

const game = new Phaser.Game(config);