Jump to content

Having trouble with "PIXI.CanvasRenderer"


vmars316
 Share

Recommended Posts

Hello & Thanks ,


I am trying to change from AutodectRenderer to PIXI.CanvasRenderer 

to avoid loading local image file .
 
I know this is not the recommended way , but I need to work it thru .
And I am using the following example from here 
https://www.dropbox.com/s/luosps9lpaacs9p/pixi-image-test.zip?dl=0&preview=pixi-image-test.zip :
 and it works fine . 

var renderer = new PIXI.CanvasRenderer( 640, 480 );
document.body.appendChild( renderer.view );

var stage = new PIXI.Container();

// create a texture from an image path
var image = new Image();
image.src = 'awesome.jpg';

setTimeout( function() {
  var base = new PIXI.BaseTexture( image )
  var texture = new PIXI.Texture( base )
  var bunny = new PIXI.Sprite( texture )
  stage.addChild( bunny )
  renderer.render( stage )
}, 10 )

Here is my code :

//Aliases
// var 

//Create a Pixi stage and renderer and add the 
//renderer.view to the DOM
var stage = new PIXI.Container();
var    renderer = PIXI.CanvasRenderer(600, 480);
document.body.appendChild(renderer.view);
// Set the background color of the renderer to a baby-blue'ish color
renderer.backgroundColor = 0x3498db;
// create a texture from an image path
var truth02 = new Image();
truth02.src = 'truth02.png';

//PIXI.loader
//  .add("truth02")
//  .load(setup);
//Define any variables that are used in more than one function
 
//function setup() {
//  truth02.y = 96; 
//  stage.addChild(truth02);
 
 setTimeout( function() {
  var baset02 = new PIXI.BaseTexture(truth02)
  var texturet02 = new PIXI.Texture( baset02 )
//  var bunny = new PIXI.Sprite( texture02 )
  stage.addChild( texturet02 )
  renderer.render( stage )
   gameLoop()
}, 10 )
 
  //Start the game loop
//  gameLoop();
//}
function gameLoop(){
  //Loop this function 60 times per second
  requestAnimationFrame(gameLoop);
  //Move the sprite02 1 pixel per frame
  truth02.x += 1;
  //Render the stage
  renderer.render(stage);
}

ERROR in Chrome: 
I am getting the following error :
Uncaught TypeError: this.initPlugins is not a function  CanvasRenderer.js:115 .

It runs in IE , but yields only a blank screen .
Pls , what am I doing wrong ?
Thanks


 

awesome.jpg

truth02.png

Link to comment
Share on other sites

1 hour ago, xerver said:

The missing new is the problem.

Hi xerver ,

Thanks for the help . 

I hope your book comes out in eBook .
I mean ebook in Print , not pictures .
I bought the 'Learn pixi.js' book .
It said ebook , but it was pictures , not print .
So I couldn't copy code .
So I sent it back . 

WHen will your's be ready ?


 

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