flatliner Posted March 13, 2021 Share Posted March 13, 2021 app.loader.add('images/pentamino.json') .load(() => { setup(); }); let tileset = app.loader.resources['images/pentamino.json']; let part:PIXI.Sprite = new PIXI.Sprite(tileset.textures['pink.png']); It generates an error: "Object is possibly 'undefined'" related to PIXI.Sprite() argument tileset.textures['pink.png']. Is it possible to fix this in anyway or better reject typescript to recycled bin? Quote Link to comment Share on other sites More sharing options...
spassvogel Posted March 14, 2021 Share Posted March 14, 2021 Use let part:PIXI.Sprite = new PIXI.Sprite(tileset.textures['pink.png']!); flatliner 1 Quote Link to comment Share on other sites More sharing options...
flatliner Posted March 17, 2021 Author Share Posted March 17, 2021 On 3/15/2021 at 12:15 AM, spassvogel said: Use let part:PIXI.Sprite = new PIXI.Sprite(tileset.textures['pink.png']!); Yes, but this: let part:PIXI.Sprite = new PIXI.Sprite(tileset.textures!['pink.png']); ... and how could I have missed this feature when studying typescript ... Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.