JSFiddle - React, Tailwind, and code Playground

by georgie

HTML

<script src="http://dat-gui.googlecode.com/git/build/dat.gui.js"></script>
<script src="https://rawgit.com/GoodBoyDigital/pixi.js/1692d11e2343baec736f066c4c8520a5687f6d53/bin/pixi.js"></script>

JavaScript

var params = { tilewidth:500, tilex: 1.1,spritewidth:"-1",round:false, scale:1 };
var gui = new dat.GUI();
gui.add(params,'tilex',0,1100);
gui.add(params,'round').name('Rounding Tile X?');
gui.add(params,'scale',90, 110, 20).name('Tile Scaling');
var changeTileWidth = gui.add(params, 'tilewidth',100,10000).name('Tilewidth:')
gui.add(params, 'spritewidth').name('spritewidth:').listen();

var forceCanvas = false;
var renderer = PIXI.autoDetectRenderer(window.innerWidth,window.innerHeight, {
}, forceCanvas);
document.body.appendChild(renderer.view);

var stage = new PIXI.Container();

var assetLoader = new PIXI.loaders.Loader();
assetLoader.add("http://2vc.org/temp/sprite-0.json");
var theTile;
assetLoader.once('complete', function(){
    console.log('loaeded');
    
    var tx = PIXI.Texture.fromFrame('ceiling.png');
    params.spritewidth = tx.baseTexture.width+' ';
    console.log(tx);
    theTile = new PIXI.extras.TilingSprite(tx, 1000, 800);
    theTile.scale.set(1);
    theTile.y = 0;
    stage.addChild(theTile);
});

assetLoader.load();
changeTileWidth.onChange(function(value){
   theTile.width = value;
});
requestAnimationFrame(animate);

function animate() {
	renderer.render(stage);   
  	requestAnimationFrame(animate);
    
    if(theTile){
        theTile.tilePosition.x=-params.tilex
       theTile.scale.set(params.scale/100);
        if(params.round){
            theTile.tilePosition.x = Math.round(theTile.tilePosition.x);
        }
    }
}