• Content Count

  • Joined

  • Last visited

  1. Yummy2828

    Cannot assign sprite to class variable

    Thanks for the advice. I've encountered this sort of problem in the past and I wasn't aware of it in this situation. I guess the next time I see a null error when I'm not supposed to, I'll remember the new arrow function https://hackernoon.com/javascript-es6-arrow-functions-and-lexical-this-f2a3e2a5e8c4
  2. I'm using Typescript to code a canvas using pixi. I've been declaring initial variable names such as container1: PIXI.Container; container2: PIXI.Container; sprite1: PIXI.Sprite; sprite2: PIXI.Sprite; as so on. Container seems to work fine as I declare new containers in a function When I use PIXI.loader to declare the new sprite, pixiLoaderInit() { PIXI.loader .add(["directory of image"]) .load(setup); function setup() { this.sprite1 = PIXI.loader.resources["directory of image"].texture console.log("done"); } } I get the following errors on FireFox ERROR TypeError: "this is null" and Chrome ERROR TypeError: Cannot set property 'sprite1' of null at setup Any solutions to this?