GithubHelp home page GithubHelp logo

Comments (8)

SuperSodaSea avatar SuperSodaSea commented on April 28, 2024

Can you provide code to reproduce your problem?

from pixijs.

gonulbuya avatar gonulbuya commented on April 28, 2024
const app = new PIXI.Application({ background: '#1099bb', resizeTo: window });

document.body.appendChild(app.view);

// create a new Sprite from an image path
const bunny = PIXI.Sprite.from('https://pixijs.com/assets/bunny.png');

// center the sprite's anchor point
bunny.anchor.set(0.5);

// move the sprite to the center of the screen
bunny.x = app.screen.width / 2;
bunny.y = app.screen.height / 2;

app.stage.addChild(bunny);

// Listen for animate update
app.ticker.add((delta) =>
{
    // just for fun, let's rotate mr rabbit a little
    // delta is 1 if running at 100% performance
    // creates frame-independent transformation
    bunny.rotation += 0.1 * delta;
});

It works smoothly with pixijs v7. When I test it with v8, I can't see anything on the screen.

Uncaught TypeError: Cannot read properties of undefined (reading 'canvas')
at get view [as view] (pixi.min.js:442:22899)

I get this error.

from pixijs.

SuperSodaSea avatar SuperSodaSea commented on April 28, 2024

In v8 you need to initialize PixiJS like this:

const app = new PIXI.Application();

await app.init({ background: '#1099bb', resizeTo: window });

document.body.appendChild(app.canvas);

from pixijs.

gonulbuya avatar gonulbuya commented on April 28, 2024

It does not work. The same error continues.

from pixijs.

bigtimebuddy avatar bigtimebuddy commented on April 28, 2024

Works fine here:
https://codesandbox.io/p/sandbox/nervous-sea-s7856y

from pixijs.

gonulbuya avatar gonulbuya commented on April 28, 2024

With this last example I didn't get the error.

from pixijs.

bigtimebuddy avatar bigtimebuddy commented on April 28, 2024

Then what was the issue? Can we close this?

from pixijs.

gonulbuya avatar gonulbuya commented on April 28, 2024

const app = new PIXI.Application({ background: '#1099bb', resizeTo: window });

document.body.appendChild(app.view);

// create a new Sprite from an image path
const bunny = PIXI.Sprite.from('https://pixijs.com/assets/bunny.png');

// center the sprite's anchor point
bunny.anchor.set(0.5);

// move the sprite to the center of the screen
bunny.x = app.screen.width / 2;
bunny.y = app.screen.height / 2;

app.stage.addChild(bunny);

// Listen for animate update
app.ticker.add((delta) =>
{
// just for fun, let's rotate mr rabbit a little
// delta is 1 if running at 100% performance
// creates frame-independent transformation
bunny.rotation += 0.1 * delta;
});

When the problem is like the code I wrote above, I get an error.

https://codesandbox.io/p/sandbox/nervous-sea-s7856y

This example working.

yes you can turn it off

from pixijs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.