forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSamplePlugin.js
37 lines (27 loc) · 854 Bytes
/
SamplePlugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* A Sample Plugin demonstrating how to hook into the Phaser plugin system.
*/
Phaser.Plugin.SamplePlugin = function (game, parent) {
Phaser.Plugin.call(this, game, parent);
this.sprite = null;
};
// Extends the Phaser.Plugin template, setting up values we need
Phaser.Plugin.SamplePlugin.prototype = Object.create(Phaser.Plugin.prototype);
Phaser.Plugin.SamplePlugin.prototype.constructor = Phaser.Plugin.SamplePlugin;
/**
* Add a Sprite reference to this Plugin.
* All this plugin does is move the Sprite across the screen slowly.
* @type {Phaser.Sprite}
*/
Phaser.Plugin.SamplePlugin.prototype.addSprite = function (sprite) {
this.sprite = sprite;
};
/**
* This is run when the plugins update during the core game loop.
*/
Phaser.Plugin.SamplePlugin.prototype.update = function () {
if (this.sprite)
{
this.sprite.x += 0.5;
}
};