Jump to content

Assigning PIXI a canvas?


achexi
 Share

Recommended Posts

In the older versions of pixi I used to be able to create a canvas in my html document and do something like this:

view = document.getElementById('game-canvas');renderer = PIXI.autoDetectRenderer(this.GAME_WIDTH, this.GAME_HEIGHT, view);

However in the newer versions of pixi the canvas simply does not appear on screen. I don't get errors or anything, the only way I can get a canvas is if I let pixi make one for me via something like:

renderer = PIXI.autoDetectRenderer(this.GAME_WIDTH, this.GAME_HEIGHT);document.body.appendChild(renderer.view);

What's changed and what must I do to force PIXI to use a canvas I make on the screen?

Link to comment
Share on other sites

You pass the canvas through as a property of an options object, see the info on the pixi github page:

 

*** IMPORTANT - V2 API CHANGES ***

A heads up for anyone updating their version of pixi.js to version 2, as we have changed a couple of bits that you need to be aware of. Fortunately, there are only two changes, and both are small.

1: Creating a renderer now accepts an options parameter that you can add specific settings to:

// an optional object that contains the settings for the renderer
var options = {
view:myCanvas,
resolution:1
};

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