Jump to content

Using atlas with typescript


flatliner
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...