SamplePlugin.js 890 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * A Sample Plugin demonstrating how to hook into the Phaser plugin system.
  3. * @class Phaser.Plugin.SamplePlugin
  4. */
  5. Phaser.Plugin.SamplePlugin = function (game, parent) {
  6. Phaser.Plugin.call(this, game, parent);
  7. this.sprite = null;
  8. };
  9. // Extends the Phaser.Plugin template, setting up values we need
  10. Phaser.Plugin.SamplePlugin.prototype = Object.create(Phaser.Plugin.prototype);
  11. Phaser.Plugin.SamplePlugin.prototype.constructor = Phaser.Plugin.SamplePlugin;
  12. /**
  13. * Add a Sprite reference to this Plugin.
  14. * All this plugin does is move the Sprite across the screen slowly.
  15. * @type {Phaser.Sprite}
  16. */
  17. Phaser.Plugin.SamplePlugin.prototype.addSprite = function (sprite) {
  18. this.sprite = sprite;
  19. };
  20. /**
  21. * This is run when the plugins update during the core game loop.
  22. */
  23. Phaser.Plugin.SamplePlugin.prototype.update = function () {
  24. if (this.sprite)
  25. {
  26. this.sprite.x += 0.5;
  27. }
  28. };