Jump to content

missing something very basic about pixi.js....trying and failing to render a single sprite


kvp0
 Share

Recommended Posts

hi everyone. i am trying to render a single sprite, just to see if i can get this library working so i can then transition a bigger project to using it. i am using webpack. not getting any errors in chrome and really lost on what im doing wrong. heres my code:

import * as PIXI from 'pixi.js'
import { roomSceneManifest } from './image_imports.js'

async function loadAssets (){
  const app = new PIXI.Application()
  await app.init({ width: 800, height: 600 });
  document.body.appendChild(app.canvas);

  PIXI.Assets.init({manifest: roomSceneManifest})

  const assets = await PIXI.Assets.loadBundle('png');
  console.log(assets)
  const bg = PIXI.Sprite.from(assets.BackgroundImg);
  console.log(bg)
  bg.anchor.set(0.5);
  bg.x = app.screen.width / 2;
  bg.y = app.screen.height / 2;
  app.stage.addChild(bg);
}

loadAssets()




./image_imports.js

export const roomSceneManifest =  {
   "bundles":[
      {
         "name":"png",
         "assets":[
            {
               "alias":"BackgroundImg",
               "src":BackgroundImg
            }
         ]
      }
   ]
}

 

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...