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

Updated pacman arc chomp chomp example to ES6 #352

Open
wants to merge 3 commits 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
76 changes: 41 additions & 35 deletions public/src/game objects/graphics/pacman arc chomp chomp.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
var config = {
class Example extends Phaser.Scene
{
constructor () {
super();
}

create ()
{
const graphics = this.add.graphics();

this.tweens.addCounter({
from: 0,
to: 30,
duration: 200,
yoyo: true,
repeat: -1,
onUpdate: function (tween)
{
let t = tween.getValue();

graphics.clear();
graphics.fillStyle(0xffff00, 1);
graphics.slice(260, 300, 200, Phaser.Math.DegToRad(330 + t), Phaser.Math.DegToRad(30 - t), true);
graphics.fillPath();

graphics.fillStyle(0x000000, 1);
graphics.fillEllipse(260, 180, 30, 90);

graphics.fillStyle(0xffffff, 1);
graphics.fillCircle(580, 300, 30);
graphics.fillCircle(740, 300, 30);
}
});

}
}

const config =
{
width: 800,
height: 600,
backgroundColor: '#010166',
type: Phaser.AUTO,
parent: 'phaser-example',
scene: {
create: create
}
scene: [ Example ]
};

var game = new Phaser.Game(config);

function create ()
{
var graphics = this.add.graphics();

this.tweens.addCounter({
from: 0,
to: 30,
duration: 200,
yoyo: true,
repeat: -1,
onUpdate: function (tween)
{
var t = tween.getValue();

graphics.clear();
graphics.fillStyle(0xffff00, 1);
graphics.slice(260, 300, 200, Phaser.Math.DegToRad(330 + t), Phaser.Math.DegToRad(30 - t), true);
graphics.fillPath();

graphics.fillStyle(0x000000, 1);
graphics.fillEllipse(260, 180, 30, 90);

graphics.fillStyle(0xffffff, 1);
graphics.fillCircle(580, 300, 30);
graphics.fillCircle(740, 300, 30);
}
});

}
const game = new Phaser.Game(config);