Tarion Posted January 6, 2014 Share Posted January 6, 2014 Hi, I'm looking for definitions of the PIXI classes used inside Phaser. Especially the PIXI.DisplayObject which I like to extend to be able to store my custom classes inside a groups. Maybe it's the wrong approach, what I'm trying is the following:npcs:Phaser.Group;// ...var npc = new Npc(this.world.randomX, this.world.randomY, this);this.npcs.add(npc);Using:export class Npc extends Mobile {// ... export interface IMobile { Sprite:Phaser.Sprite; update(); } export class Mobile implements IMobile { Sprite:Phaser.Sprite; update() { } }But it fails with: Uncaught TypeError: Cannot set property '_iPrev' of undefined phaser.js:1559:27PIXI.DisplayObjectContainer.addChild phaser.js:1559:27 Link to comment Share on other sites More sharing options...
rich Posted January 6, 2014 Share Posted January 6, 2014 Your approach is fine but your interface doesn't look quite right. Group.add expects you to give it a valid display object, but Mobile doesn't extend a display object, it just seems to have one as a property. There's no TypeScript definitions file for Pixi yet I don't believe, but the second they finish making one we'll merge it with our defs file too! Link to comment Share on other sites More sharing options...
Tarion Posted January 6, 2014 Author Share Posted January 6, 2014 I know that the DisplayObject is missing, but the DisplayObject is part of PIXI and I did not managed to add it to the definition (don't even need a full PIXI definition). If one could provide me just the "DisplayObject" definition that would help a lot. Link to comment Share on other sites More sharing options...
rich Posted January 6, 2014 Share Posted January 6, 2014 You could always create one? I don't expect there are that many properties in a DisplayObject. It shouldn't take too long to type one out. Link to comment Share on other sites More sharing options...
Tarion Posted January 6, 2014 Author Share Posted January 6, 2014 I took a few tries but it did not worked. Maybe I post them later so one can help me to get it right. For now I live without it. Link to comment Share on other sites More sharing options...
rich Posted January 6, 2014 Share Posted January 6, 2014 I've seen scripts that try to generate defs automatically from JS source. But I've never seen one that worked that well The Phaser defs file used one and we had to manually fix it by hand. Took forever. Probably could have written my own in the time it took us to manually edit! Link to comment Share on other sites More sharing options...
Recommended Posts