presidenten Posted October 13, 2015 Share Posted October 13, 2015 Hi! Which plugins work with with Panda 2 (develop branch)? Fader did not want to work :/Can I use P2 or box2d? Quote Link to comment Share on other sites More sharing options...
zakhov Posted October 15, 2015 Share Posted October 15, 2015 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(); Quote Link to comment Share on other sites More sharing options...
enpu Posted October 15, 2015 Share Posted October 15, 2015 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 zakhov 1 Quote Link to comment Share on other sites More sharing options...
zakhov Posted October 15, 2015 Share Posted October 15, 2015 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.