Rayj Posted June 16, 2015 Share Posted June 16, 2015 Can someone provide install instructions for Pixi.js? I am interested in developing an HTML5 game. I just ran into pixi and would like to try it. Remember, I am totally new at this, so tell me like a 5 year old. Thanks, Ray Quote Link to comment Share on other sites More sharing options...
Rayj Posted June 16, 2015 Author Share Posted June 16, 2015 293 views and no help? How can I get the pixi examples running using Apache web server? How do I use the pre built releases at https://github.com/GoodBoyDigital/pixi.js/releases running? Quote Link to comment Share on other sites More sharing options...
xerver Posted June 16, 2015 Share Posted June 16, 2015 What have you tried? There are a lot of tutorials around the internet. The examples have a readme that explains how to get them running. Pixi's readme has basic usage examples. If you have never written a line of html/js them Pixi may not be the best place to start. Read through the MDN for a bit. Quote Link to comment Share on other sites More sharing options...
Rayj Posted June 17, 2015 Author Share Posted June 17, 2015 What have you tried? There are a lot of tutorials around the internet. The examples have a readme that explains how to get them running. Pixi's readme has basic usage examples. If you have never written a line of html/js them Pixi may not be the best place to start. Read through the MDN for a bit.I am trying an example at: http://modernweb.com/2013/11/04/building-a-parallax-scrolling-game-with-pixi-js/#comment-78088You can see the demo in action here: http://www.yeahbutisitflash.com/pixi-parallax-scroller/final/index.html The initial stage light grey on black is fine.But from the point where it says the stage turns green and forward, it does not work!I followed the tutorial directly. Here is where I left off. Please let me know where I went wrong. <html> <head> <meta charset="UTF-8"> <title>Parallax Scrolling Demo</title><meta charset="UTF-8"> <title>Endless Runner Game Demo</title> <style> body { background-color: #000000; } canvas { background-color: #222222; } </style> </head> <body onload="init();"> <div align="center"> <canvas id="game-canvas" width="512" height="384"></canvas> </div> <script src="pixi.js-master/bin/pixi.js"></script><script> function init() {stage = new PIXI.Stage(0x66FF99);renderer = PIXI.autoDetectRenderer( 512, 384, document.getElementById("game-canvas") );var farTexture = PIXI.Texture.fromImage("resources/bg-far.png");far = new PIXI.Sprite(farTexture); far.position.x = 0; far.position.y = 0;^?stage.addChild(far);var midTexture = PIXI.Texture.fromImage("resources/bg-mid.png"); mid = new PIXI.Sprite(midTexture); mid.position.x = 0; mid.position.y = 128; stage.addChild(mid);requestAnimFrame(update); }function update() { far.position.x -= 0.128; mid.position.x -= 0.64; renderer.render(stage); requestAnimFrame(update);} </script> </body></html> Quote Link to comment Share on other sites More sharing options...
xerver Posted June 17, 2015 Share Posted June 17, 2015 Well that tutorial looks like it written for Pixi v2, and if you downloaded the latest from GitHub that is v3. So they are not compatible. As far as your code:there is a random "^?" in there, which I think might have been a copy-paste error but otherwise is a syntax error.Replace the Stage with a normal Container.You are also using requestAnimFrame which isn't a thing anymore in v3, you should be using the standard requestAnimationFrame().The third parameter of autoDetectRenderer is options to pass the renderer, not the element. Instead do { backgroundColor: 0x66FF99, view: document.getElementById('game-canvas') }Here is a working, cleaned up version:<html> <head> <meta charset="UTF-8"> <title>Parallax Scrolling Demo</title> <meta charset="UTF-8"> <title>Endless Runner Game Demo</title> <style> body { background-color: #000000; } canvas { background-color: #222222; } </style> </head> <body onload="init();"> <div align="center" id="container"> <canvas id="game-canvas" width="512" height="384"></canvas> </div> <script src="pixi.js-master/bin/pixi.js"></script> <script> function init() { stage = new PIXI.Container(); renderer = PIXI.autoDetectRenderer(512, 384, { backgroundColor: 0x66FF99, view: document.getElementById('game-canvas') }); far = new PIXI.Sprite.fromImage("resources/bg-far.png"); far.position.x = 0; far.position.y = 0; stage.addChild(far); mid = new PIXI.Sprite.fromImage('resources/bg-mid.png'); mid.position.x = 0; mid.position.y = 128; stage.addChild(mid); update(); } function update() { far.position.x -= 0.128; mid.position.x -= 0.64; renderer.render(stage); requestAnimationFrame(update); } </script> </body></html>You could see a lot of these errors by opening up the developer console (Ctrl+Shift+I or F12 in Chrome) and seeing the errors in the Console tab. Quote Link to comment Share on other sites More sharing options...
Rayj Posted June 17, 2015 Author Share Posted June 17, 2015 Well that tutorial looks like it written for Pixi v2, and if you downloaded the latest from GitHub that is v3. So they are not compatible. As far as your code:there is a random "^?" in there, which I think might have been a copy-paste error but otherwise is a syntax error.Replace the Stage with a normal Container.You are also using requestAnimFrame which isn't a thing anymore in v3, you should be using the standard requestAnimationFrame().The third parameter of autoDetectRenderer is options to pass the renderer, not the element. Instead do { backgroundColor: 0x66FF99, view: document.getElementById('game-canvas') }Here is a working, cleaned up version:<html> <head> <meta charset="UTF-8"> <title>Parallax Scrolling Demo</title> <meta charset="UTF-8"> <title>Endless Runner Game Demo</title> <style> body { background-color: #000000; } canvas { background-color: #222222; } </style> </head> <body onload="init();"> <div align="center" id="container"> <canvas id="game-canvas" width="512" height="384"></canvas> </div> <script src="pixi.js-master/bin/pixi.js"></script> <script> function init() { stage = new PIXI.Container(); renderer = PIXI.autoDetectRenderer(512, 384, { backgroundColor: 0x66FF99, view: document.getElementById('game-canvas') }); far = new PIXI.Sprite.fromImage("resources/bg-far.png"); far.position.x = 0; far.position.y = 0; stage.addChild(far); mid = new PIXI.Sprite.fromImage('resources/bg-mid.png'); mid.position.x = 0; mid.position.y = 128; stage.addChild(mid); update(); } function update() { far.position.x -= 0.128; mid.position.x -= 0.64; renderer.render(stage); requestAnimationFrame(update); } </script> </body></html>You could see a lot of these errors by opening up the developer console (Ctrl+Shift+I or F12 in Chrome) and seeing the errors in the Console tab.Thanks for the info. I did see some of these error in Chrome, but I didn't know this example was not compatible with v3.0.6.Could you point me to an example with source code that is compatible with v3.0.6? Thanks, Ray Quote Link to comment Share on other sites More sharing options...
d13 Posted June 17, 2015 Share Posted June 17, 2015 Can someone provide install instructions for Pixi.js? You can try this:https://github.com/kittykatattack/learningPixi Quote Link to comment Share on other sites More sharing options...
Rayj Posted June 17, 2015 Author Share Posted June 17, 2015 You can try this:https://github.com/kittykatattack/learningPixiWow. Thanks! Off I go to play! 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.