JanV Posted June 27, 2015 Share Posted June 27, 2015 var Container = PIXI.Container, loader = PIXI.loader, Sprite = PIXI.Sprite, resources = PIXI.loader.resources;var renderer = PIXI.autoDetectRenderer(256, 256);document.body.appendChild(renderer.view);var stage = new Container();renderer.backgroundColor = 0xffffff;renderer.render(stage);loader .add("images/ant.png") .on("progress", loadProgressHandler) .load(setup);function loadProgressHandler(loader, resource) { console.log(loader.progress);}var ant;function setup() { ant = new Sprite.fromImage("images/ant.png"); stage.addChild(ant); renderer.render(stage); renderer.view.style.position = "absolute" renderer.view.style.width = window.innerWidth + "px"; renderer.view.style.height = window.innerHeight + "px"; renderer.view.style.display = "block"; gameLoop();}function gameLoop() { requestAnimationFrame(gameLoop); renderer.render(stage);}This is how my game.js script actually looks like and so far I'm quite happy with what it's doing. But my problem is that all sprites I render on my canvas are distorted and do not keep their original sizes. So what am I doing wrong here?I just want to keep the original sizes of all objects I'll render on the canvas. (The ant.png image is 250x250px) How the result looks like: How the ant.png looks like: Quote Link to comment Share on other sites More sharing options...
xerver Posted June 27, 2015 Share Posted June 27, 2015 Don't set the canvas size yourself, resize the renderer:// this will ensure the canvas gets updated according to resolutionrenderer.autoResize = true;renderer.resize(width, height); d13 1 Quote Link to comment Share on other sites More sharing options...
JanV Posted June 28, 2015 Author Share Posted June 28, 2015 it works, thank you so much 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.