Jump to content

A pixi.js guide?


Barsik_The_CaT
 Share

Recommended Posts

I've got a task in my university to make a basic game using pixi.js. When I tried to do some basic stuff(load a texture from a tileset and make it move) with This guide turned out it is completely outdated and author omits PIXI prefix pretty often. Basically, even if I copy-paste the code it gives me errors with something being not defined, etc.
Is there an up-to-date guide for pixi.js? Learning a library through documentation is hard AF.

Link to comment
Share on other sites

Last time i followed guides, that one was most thorough (my knowledge is outdated). But I dont think there is anything better yet, but you can at least check the pixis own examples, you might get something out of them: https://pixijs.github.io/examples/#/basics/basic.js

And my suspicion would be that most of the info is still correct at kittykatattacks tutorials, but they just dont work directly copy pasting as few really fundemantal things might have changed :)

Link to comment
Share on other sites

An example copy/pasted from kittykatattack
 

PIXI.loader
      .add("pictures/Mech1Walk.png")
      .load(setup);

    function setup() {
      var texture = PIXI.TextureCache["pictures/Mech1Walk.png"];
      var rectangle = new PIXI.Rectangle(1, 1, 64, 64);
      texture.frame = rectangle;
      var robot = new PIXI.Sprite(texture);
      robot.x = 100;
      robot.y = 100;
      stage.addChild(robot);
      renderer.render(stage);
    }
Gives me an error:

pixi.min.js:8 Uncaught DOMException: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The cross-origin image at (location of .png file)

Link to comment
Share on other sites

Going this way:

var spritesheet = PIXI.BaseTexture.fromImage("pictures/Mech1Walk.png");
    var spritetext = new PIXI.Texture(spritesheet, new PIXI.Rectangle(1, 1, 64, 64));
    var mahsprite = new PIXI.Sprite(spritetext);
    stage.addChild(mahsprite);
    renderer.render(stage);

Gives me a blank canvas without my texture, though no errors in the console

Edited by Barsik_The_CaT
Some typos
Link to comment
Share on other sites

Are you running the page from local file system? (file://something in url).

If yes, then the browser cant load the image due to security reasons. You need to run the browser either with local file system allowed or run the page through web server or use a proxy solution like fiddler.

Link to comment
Share on other sites

On 9/11/2016 at 1:28 PM, Barsik_The_CaT said:

I've got a task in my university to make a basic game using pixi.js. When I tried to do some basic stuff(load a texture from a tileset and make it move) with This guide turned out it is completely outdated and author omits PIXI prefix pretty often. Basically, even if I copy-paste the code it gives me errors with something being not defined, etc.
Is there an up-to-date guide for pixi.js? Learning a library through documentation is hard AF.

There is an excellent little book about Pixi.js by Rex Van Der Spuy published by Apress. 

Link to comment
Share on other sites

On 13.11.2016 at 7:06 PM, raenset said:

There is an excellent little book about Pixi.js by Rex Van Der Spuy published by Apress. 

How old is it? Won't I encounter the same problem I encountered with Kittikatattack's guide?

P.S.
Just checked it, it's a really great book that also explains the changes in different versions of pixi.js
Thanks for advice!

Edited by Barsik_The_CaT
just got extra information and wanted to thank a person
Link to comment
Share on other sites

pixi.min.js:8 Uncaught DOMException: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The cross-origin image at (location of .png file)

That's not pixi problem. You are trying to serve files from static file system, right? No web-server?

Examples from that tutorial are working, the guide is accurate enough.

Link to comment
Share on other sites

On 20.11.2016 at 2:35 AM, ivan.popelyshev said:

pixi.min.js:8 Uncaught DOMException: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The cross-origin image at (location of .png file)

That's not pixi problem. You are trying to serve files from static file system, right? No web-server?

Examples from that tutorial are working, the guide is accurate enough.

No, they're not. If they are, try making a sprite from a tileset subimage using the frame property of texture
(spoilers: there is no such object, because you have to use PIXI. texture, and good luck making a sprite with syntax that is completely different from one in the example)

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