Ezelia / EZGUI

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

Tabs do not work with Phaser 2.4/2.3 #27

Closed FabianElsmer closed 9 years ago

FabianElsmer commented 9 years ago

Hey guys, When you take the Phaser Example index.html and replace the guiObj with the one from the Tabs Example, you end up getting an error. The error appears both with Phaser 2.4 and Phaser 2.3.

Tabs.ts #94 "Uncaught TypeError: this.tabsBar.container.children[order].setState is not a function"

It all seems to come down to guiobjects.ts #251 where this happens

if (child.phaserGroup) return this.container.addChild(child.phaserGroup);
                else return this.container.addChild(child);

So for the Tabs actual Phaser Sprites are used, instead of the Components.

Removing this line to always use the actual child prevents the error, but leaves the tabs unclickable.

Using

child.guiSprite.setState

works a little bit better, it seems to attempt to switch tabs, but the new content is not actually shown and the tab does not stay selected.

alaa-eddine commented 9 years ago

Good catch, this one was tricky :)

Phaser have it's own Components model, it imposes that children components to be of type Phaser.Sprite and to workaround it,when using Phaser, EZGUI will wrap it's components inside a phaser Sprite which donc containt setState function (specific to EZGUI).

I added a function to check this and execute the right code to set tabs states. tested with phaser and it's working for me.

please confirm :)

FabianElsmer commented 9 years ago

Yeah it works now.

alaa-eddine commented 9 years ago

fine :) So I'm closing this issue, thank you for reporting and test.