rolandino Posted May 27, 2014 Share Posted May 27, 2014 Hi, Apologies for the perhaps rather dim question, but I'd like to use, or try to use some of the plugins as listed at https://github.com/photonstorm/phaser-plugins. Is there any documentation as to how to *use* these plugins? Many thanks,R Link to comment Share on other sites More sharing options...
lewster32 Posted May 27, 2014 Share Posted May 27, 2014 I believe you just include the JavaScript file for the plugin after you've included the main phaser.js or phaser.min.js file. The plugins are then usually documented and/or provide examples of how to implement their features. JUL 1 Link to comment Share on other sites More sharing options...
rolandino Posted May 27, 2014 Author Share Posted May 27, 2014 Cool. Many thanks. Will give it a try when I have a mo', and will feedback.Thanks,R Link to comment Share on other sites More sharing options...
Zaidar Posted May 28, 2014 Share Posted May 28, 2014 Hi, I hesitated to create the same post couple of days ago. I was also sad that there isn't so much doc about plugins in Phaser. I was trying to use the Juicy plugin from the Phaser plugin repository. (https://github.com/photonstorm/phaser-plugins/tree/master/Juicy) So i did like this : var GameState = { create: function(){ // rest of the code this.juicy = this.game.plugins.add(new Phaser.Plugin.Juicy(this)); }, gameOver: function(bomb){ // when I need to call my plugin this.juicy.shake(); }}; PS: Pro tip : Don't forget to add the plugin script <script src="Juicy.js"></script> EDIT : Pro tip 2 : of course the use of this depend if you're using the OOP notation and game states and all that stuff. Try to play with the this value and console.log() Pro tip 3 : I'm not a pro lewster32 1 Link to comment Share on other sites More sharing options...
lewster32 Posted May 28, 2014 Share Posted May 28, 2014 Ah right, I wasn't aware the plugins had to be added like this - I assumed plugins patched themselves into Phaser when the script was included. Link to comment Share on other sites More sharing options...
Zaidar Posted May 28, 2014 Share Posted May 28, 2014 Yeah, I wasn't sure so I retested, but I confirm it doesn't work if you just do this.juicy = new Phaser.Plugin.Juicy(this); Link to comment Share on other sites More sharing options...
rolandino Posted May 28, 2014 Author Share Posted May 28, 2014 Hi,That's all super useful. Thanks. Zaidar, can you confirm that the example you gave above re: the use of the juicy plugin is the appropriate approach? i.e.this.juicy = this.game.plugins.add(new Phaser.Plugin.Juicy(this)); And ... did you get the Juicy plugin working? Do you by any chance have an example? Just wondered ..... Thanks again for replying, all very helpful. CheersR Link to comment Share on other sites More sharing options...
Zaidar Posted May 28, 2014 Share Posted May 28, 2014 Well, since it works and the plugin is part of the game.plugins array, I think that's the good solution.I have an example working for you. Let me put this online. Here is the game, the only part I use the Juicy plugin is for the screenShake effect (I know, but it was just for testing at first, so I just left it here) http://jeandaviddaviet.fr/games/Bombomb/ This is the source on Github : https://github.com/JeanDavidDaviet/Bomb-omb/blob/master/script.js Basically if you look at line 57, I'm adding the plugin into the Phaser pluginManager.And lines 157 and 169 I use the shake() function to make the screen shake.At the end, when you put a red bomb on the black container, it explodes and make the screen shakes. If you have already used OOP for your games, like a Player.js where you define a player "constructor" and player functions, this is the same thing. Plugins could just be inserted in the main code, but at the end of the day, it's just for better clarity and organisation I think. Mike 1 Link to comment Share on other sites More sharing options...
rolandino Posted May 28, 2014 Author Share Posted May 28, 2014 Zuper kool. I'll have a look when I have a mo'. Many, many thanks.R Link to comment Share on other sites More sharing options...
rolandino Posted May 28, 2014 Author Share Posted May 28, 2014 Nice. Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts