Ezelia / EZGUI

EZGUI - The missing GUI for Pixi.js and Phaser.io
http://ezgui.ezelia.com
440 stars 95 forks source link

Compatibility with phaser 2.6.1 #58

Closed kerphi closed 7 years ago

kerphi commented 8 years ago

Hello,

The ezgui plugin is working well with phaser 2.4.6 this way

    <script src="phaser-2.4.6.min.js"></script>
    <script src="phaser-compat-2.4.js"></script>

I just tested the same with phaser 2.6.1 this way:

    <script src="phaser-2.6.1.min.js"></script>
    <script src="phaser-compat-2.4.js"></script>

And this way

    <script src="phaser-2.4.6.min.js"></script>

the both seams to not working as expected, i got this error in the console when tring to use the lib:

image

Thanks a lot in advance for any idea ?

alaa-eddine commented 8 years ago

is it working with older Phaser 2.4 builds ? if so, I think that Phaser 2.4.6 introduced new breaking changes :( I'll look at this and try to add the missing feature to compatibility script.

kerphi commented 8 years ago

it works well with the phaser 2.4.6 i currently used in the past i also used phaser 2.4.4, 2.4.3 and 2.4.2 without any problems today i tried to upgrade to pahser 2.6.1 and bad suprise :-/

alaa-eddine commented 8 years ago

Ok, so the issue is with the latest update, I'll check Phaser 2.6.1 changelog to identify what have changed.

from your error message it seems that Texture.fromFrame function was removed... but it's not said that only this function was removed.

paulocoutinhox commented 8 years ago

I have the same problem here: https://www.dropbox.com/s/63t7j4pcmahidma/Screenshot%202016-07-25%2020.12.08.png?dl=0

It was solved?

Thanks

kerphi commented 8 years ago

Hello @alaa-eddine did you have any time to look at this issue ? Thanks in advance for your great work !

kerphi commented 8 years ago

Up...

alaa-eddine commented 8 years ago

Sorry for the delay, I'm very busy on a project at the moment, and have very few time but will try to fix this issue asap. the release of new Pixi v4 is a good news to everyone but it'll add complexity here :D I need to fix compatibility issues with Pixi v4 while keeping it working with Pixi v3 and Phaser.

@kerphi can you please make a test by adding the following code to the end of phaser-compat-2.4.j ?

Texture.fromFrame = function (frameId)
{
    var texture = utils.TextureCache[frameId];

    if (!texture)
    {
        throw new Error('The frameId "' + frameId + '" does not exist in the texture cache');
    }

    return texture;
};
kerphi commented 8 years ago

I just tested with phaser 2.6.1

but i first had to change Texture.fromFrame = function (frameId) to PIXI.Texture.fromFrame = function (frameId)

then i got an error un the utils var: phaser-compat-2.4.js:732 Uncaught ReferenceError: utils is not defined

alaa-eddine commented 8 years ago

I'm afraid this will not be easy to fix :( I'm checking the latest Phaser code, and it seems that they removed all PIXI TextureCache references, this is used by EZGUI to cache and load textures .... I'm not very familiar with phaser, I'm trying to find if phaser create an alternative cache in which case I can extract the texture from ...

kerphi commented 8 years ago

Great news ! i'll test too as soon as it's ready

Le dim. 28 août 2016 à 17:57, Alaa-eddine K. notifications@github.com a écrit :

Well I think I found a workaround :) fixing and making tests now ....

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Ezelia/EZGUI/issues/58#issuecomment-242982267, or mute the thread https://github.com/notifications/unsubscribe-auth/AAUCNPI3HjBx1Jz480el23PbME4m8STkks5qka_qgaJpZM4JNP86 .

alaa-eddine commented 8 years ago

Just pushed a new version. Should fix many compatibility issues. please use the new phaser compatibility file.

kerphi commented 8 years ago

I just tested your fix with phaser 2.6.2 loaded on my code

Unfortunatly, i got these errors: image

Notice: assets/ezgui/fonts/desyrel.png and assets/ezgui/fonts/Skranji-Bold-40-white.png files exists

alaa-eddine commented 8 years ago

are you using the new version of phaser-compat-2.4.js and the new version of EZGUI.js ?

also, are you using the EZGUI.Compatibility.fixCache function ? take a look at https://github.com/Ezelia/EZGUI/blob/master/examples/game/phaser-2.4.html to know how to use it.

kerphi commented 8 years ago

I just updated phaser-compat-2.4.js, should i update EZGUI too ?

and yes i use the compat fix, see snipet on my code:

  //Load des Popups EZGUI
  self.EZGUIResources = [
    'dialog-rate',
    'dialog-nofloater',
    'dialog-playergain',
    'btn_fermer',
    'btn_fermer_on',
    'diamant'
  ]

  game.load.onLoadComplete.add(EZGUI.Compatibility.fixCache, game.load, null, self.EZGUIResources);
alaa-eddine commented 8 years ago

yes you need the new EZGUI version, in the console you should see EZGUI v0.3.2.

use the one available here : https://github.com/Ezelia/EZGUI/tree/master/dist

kerphi commented 8 years ago

I got something almost working.

I justed updated EZGUI.js image

Then i added the png font in the fixCache issue:

  game.load.image('ezgui-font', '/assets/ezgui/fonts/Skranji-Bold-40-white.png?cb='+self.cbuster);

  //Load des Popups EZGUI
  self.EZGUIResources = [
    'dialog-rate',
    'dialog-nofloater',
    'dialog-playergain',
    'btn_fermer',
    'btn_fermer_on',
    'diamant',
    'ezgui-font'
  ]

  game.load.onLoadComplete.add(EZGUI.Compatibility.fixCache, game.load, null, self.EZGUIResources);

(but that's wired as it worked well without this before the upgrade)

Then my popup is displaying ! But if i close it thanks to a close button i added in the popup, then if i try to create it again (or another) i cannot close it anymore. It seams there is a problem with the on click event :(

alaa-eddine commented 8 years ago

Actually, Phaser also changed the way it handles touch/mous events from v 2.4.9+ .... I fixed some compatibility issues related to that, this is why EZGUI update was mandatory.

from what you describe, it seems that there is still an issue with events handling. I need to check something.

when you create the popup again, can you please try to run the following code in the console. then try to close the popup ?

                    for (var c in EZGUI.components) {
                        var _this = EZGUI.components[c];
                        if (_this.phaserGroup && _this.phaserGroup.input && _this.guiParent && _this.guiParent.phaserGroup && _this.guiParent.phaserGroup.input) {

                            _this.phaserGroup.input.priorityID = _this.guiParent.phaserGroup.input.priorityID + 1;

                        }
                    }
kerphi commented 8 years ago

I tried. Unfortunatly, it doesn't fix the bug. The button is still not clickable. I checked also one thing: we are going well in the "if" in your piece of code (i added a console.log inside to check that)

alaa-eddine commented 8 years ago

I'm pretty sure it's linked to the new property introduced by phaser (priorityID) but I need to reproduce the issue in a code I can debug.

this code uses phaser 2.6 and is working : https://github.com/Ezelia/EZGUI/blob/master/examples/game/phaser-2.4.html

if you can start from it and reproduce your issue, it'll be very helpful to find a fix.

kerphi commented 8 years ago

It was hard but i thing i was able to reproduce my bug on the phaser-2.4.html file.

Just add this code just after line 165:

      mainScreen.destroy();
      avatarSelectScreen.destroy();
      levelSelectScreen.destroy();
      fakeGameScreen.destroy();
      dlg1.destroy();
      dlg2.destroy();

      mainScreen = EZGUI.create(mainScreenJSON, 'metalworks');

      avatarSelectScreen = EZGUI.create(avatarSelectScreenJSON, 'metalworks');
      avatarSelectScreen.visible = false;

      levelSelectScreen = EZGUI.create(levelSelectScreenJSON, 'metalworks');
      levelSelectScreen.visible = false;

      fakeGameScreen = EZGUI.create(fakeGameScreenJSON, 'metalworks');
      fakeGameScreen.visible = false;

      var dlg1  = EZGUI.create(dialog1JSON, 'metalworks');
      dlg1.visible=false;
      var dlg2  = EZGUI.create(dialog2JSON, 'metalworks');
      dlg2.visible=false;     

      setupGUI();   

i think it simulates what i do in my code: destroying the popup (when it is closed) then recreating it from scratch.

alaa-eddine commented 8 years ago

if the above code reproduce your behaviour then it's not related to phaser 2.6 compatibility. I tried with phaser 2.4.2 and the events don't fire when recreating the gui elements.

this is wired, I need to check in details how phaser 2.4+ handle events registration

kerphi commented 8 years ago

there should be other side effects because my code worked well with phaser 2.4.2 ...

GrimPanda commented 8 years ago

As a small note, phaser-compat-2.4.js is only updated in the /js directory, but it's not updated elsewhere such as /dist

alaa-eddine commented 7 years ago

Sorry for this I just pushed an update to fix it . thank you @GrimPanda :)