Creating new plugin

Plugin looks like any other game module and it can contain any JavaScript code.

Here is basic syntax of Panda 2 plugin:

game.module(
    'plugin.example'
)
.body(function() {
    
// Insert JavaScript code here

});

Note that plugin name should match the filename of the plugin. For example plugin named plugin.example should be in file named example.js

Example

Here is example plugin, that inject's new method into Rectangle class.

game.module(
    'plugin.example'
)
.require(
    'engine.geometry'
)
.body(function() {
    
game.Rectangle.inject({
    size: function() {
        return this.width * this.height;
    }
});

});

Then you would use that plugin in your game like this:

game.module(
    'game.main'
)
.require(
    'plugin.example'
)
.body(function() {
    
game.createScene('Main', {
    init: function() {
        var rect = new game.Reactangle(10, 20);
        console.log(rect.size()); // 200
    }
});

});