git @ Cat's Eye Technologies Cyclobots / 254c5ff
Use pixi-viewport too, so we can scroll the bots back into view. Chris Pressey 3 years ago
2 changed file(s) with 18 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
00 /*
1 * pixi-min.js and cyclobots.js must be loaded before this source.
1 * pixi-min.js, pixi-viewport.js, and cyclobots.js must be loaded before this source.
22 * After loading this source, call launch() to create and start the gewgaw.
33 */
44
1212 });
1313
1414 config.container.appendChild(app.view);
15
16 var viewport = new PIXI.extras.Viewport({
17 screenWidth: config.width,
18 screenHeight: config.height,
19 worldWidth: 1000,
20 worldHeight: 1000,
21 interaction: app.renderer.plugins.interaction
22 });
23 console.log(viewport);
24
25 app.stage.addChild(viewport);
26 viewport.drag();
1527
1628 var c = new Cyclobots().init({
1729 width: config.width,
4052 graphics.beginFill(0xff0000);
4153 graphics.drawCircle(0, 0, 10);
4254 graphics.endFill();
43 app.stage.addChild(graphics);
55 viewport.addChild(graphics);
4456 bot.graphics = graphics;
4557 });
4658 }
5466 graphics.drawCircle(0, 0, 10);
5567 graphics.endFill();
5668 graphics.filters = [new PIXI.filters.BlurFilter()];
57 app.stage.addChild(graphics);
69 viewport.addChild(graphics);
5870 bot.graphics = graphics;
5971 });
6072 }
2525 </div>
2626 </div>
2727
28 <!-- to run this offline, download this file and change this URL to point to your local copy of pixi.min.js -->
28 <!-- to run this offline, download these files and change these URLs to point to your local copies of them -->
2929 <script src="https://catseye.tc/contrib/pixi.js-v4.8.5/pixi.min.js"></script>
30 <script src="https://catseye.tc/contrib/pixi-viewport.js-3.4.1/pixi-viewport.min.js"></script>
31
3032 <script src="../src/cyclobots.js"></script>
3133 <script src="cyclobots-pixi-launcher.js"></script>
3234 <script>