komali2

Members
  • Content Count

    2
  • Joined

  • Last visited

  1. komali2

    What's the proper way to extend a Pixi.Sprite class?

    Ah, finally turned up something helpful: https://sprite-storm.com/tutorial/pixi-tutorial/dynamic-button-class-pixi-js/ not yet implemented it yet but will comment further if this turned out useful
  2. We're trying to figure the best way to generate our own custom Pixi.Sprite classes in a webpack built, typescript included app. What we're hoping to do, is something along these lines (which we've gotten working but have massive tslint errors from: export class customSpriteClass { constructor(imageURL){ const customSprite: PIXI.Sprite = PIXI.Sprite.fromImage(imageURL); //custom methods, variables, etc return customSprite; } } What we can't figure out is the "proper" way to do this. The above works, but our efforts to modify customSprite with methods that refer to `this` cause tslint errors about given properties not existing on the customSpriteClass type, the return statement results in the super weird "Return type of constructor signature must be assignable to the instance type of the class." error, and our methods throw all sorts of different errors. We tried doing something like "export class customSpriteClass extends PIXI.Sprite", but to get that working we still need to invoke ".fromImage" anyway... It's a bit messy and we're hoping to find someone that's gone through this path already - I've been googling for about an hour and have yet to turn up anything definitive, weirdly. So: Anybody out there ever successfully extend PIXI.Sprite to make their own custom sprite classes? Particularly in typescript?