Jump to content

Plugins working with Panda 2?


presidenten
 Share

Recommended Posts

Fader plugin is working for me here in Panda 2.0. Made some alterations to the code though.

game.module(    'plugins.fader').body(function() {    game.createClass('Fader', {    color: 0x000000,    speed: 500,    fading: false,    init: function(settings) {        game.merge(this, settings);        this.sprite = new game.Graphics();        this.sprite.beginFill(this.color);        this.sprite.drawRect(0, 0, game.system.width, game.system.height);    },    fadeIn: function(callback) {        this.stop();        this.callback = callback;        if (this.sprite.alpha === 0) this.sprite.alpha = 1;        this.sprite.addTo(this.stage);        this.tweenIn = new game.Tween(this.sprite);        this.tweenIn.to({ alpha: 0 }, this.speed);        this.tweenIn.onComplete(this.fadeComplete.bind(this, true));        this.tweenIn.start();        this.fading = true;    },    fadeOut: function(callback) {        this.stop();        this.callback = callback;        if (this.sprite.alpha === 1) this.sprite.alpha = 0;        this.sprite.addTo(this.stage);        this.tweenOut = new game.Tween(this.sprite);        this.tweenOut.to({ alpha: 1 }, this.speed);        this.tweenOut.onComplete(this.fadeComplete.bind(this));        this.tweenOut.start();        this.fading = true;    },    fadeComplete: function(remove) {        this.fading = false;        this.stop();        if (typeof this.callback === 'function') this.callback();        if (remove) this.stage.removeChild(this.sprite);    },    stop: function() {        if (this.tweenIn) {            this.tweenIn.stop();            this.tweenIn = undefined;        }        if (this.tweenOut) {            this.tweenOut.stop();            this.tweenOut = undefined;        }    }});});

The you call it when transitioning to another scene (call it sceneNextScene for example) like this:

this.addTimer(1000,function(){ game.system.setScene('sceneNextScene'); });this.fader = new game.Fader({color: 0xffffff, speed: 1000, stage: this.stage});this.fader.fadeOut();
Link to comment
Share on other sites

You should not use addTimer, that's why there is callback function on Fader.

var fader = new game.Fader({    color: '#ff0000'});fader.fadeOut(function() {    game.system.setScene('nextScene');}); 

And color format is now string, not number.

 

I just created develop branch to plugins repo, that contains plugins that are updated to work with Panda 2 (Spine is still wip).

https://github.com/ekelokorpi/panda.js-engine-plugins/tree/develop

 

There is now working Fader plugin for Panda 2

Link to comment
Share on other sites

You should not use addTimer, that's why there is callback function on Fader.

var fader = new game.Fader({    color: '#ff0000'});fader.fadeOut(function() {    game.system.setScene('nextScene');}); 

And color format is now string, not number.

 

I just created develop branch to plugins repo, that contains plugins that are updated to work with Panda 2 (Spine is still wip).

https://github.com/ekelokorpi/panda.js-engine-plugins/tree/develop

 

There is now working Fader plugin for Panda 2

 

Cheers enpu.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...