vmars316 Posted January 16, 2016 Share Posted January 16, 2016 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 Quote Link to comment Share on other sites More sharing options...
nmiguelmoura Posted January 16, 2016 Share Posted January 16, 2016 var renderer = new PIXI.CanvasRenderer(600, 480); Hi, I think you missed the keyword new. Try changing this: var renderer = PIXI.CanvasRenderer(600, 480); to this: var renderer = new PIXI.CanvasRenderer(600, 480); Hope it works... Quote Link to comment Share on other sites More sharing options...
xerver Posted January 16, 2016 Share Posted January 16, 2016 The missing new is the problem. Quote Link to comment Share on other sites More sharing options...
vmars316 Posted January 17, 2016 Author Share Posted January 17, 2016 Oh geez , Thanks a lot guys . Quote Link to comment Share on other sites More sharing options...
vmars316 Posted January 17, 2016 Author Share Posted January 17, 2016 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 ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.