S
S
Sergey Oleinik2016-12-01 23:51:41
Android
Sergey Oleinik, 2016-12-01 23:51:41

How to scale a pixi.js scene for different resolutions?

There was a need to create a single game client code for web and mobile. On the web, the client works correctly, but the apk built with cordova has problems with scaling.
The essence of the problem: on a 720x1280 device, the following code gives the scene dimensions 360x615, and the images added to the scene have a real size, and as a result, an image with a width of 480 pixels does not fit on a screen of 360 pixels, which should have a width of 720 pixels:

var renderer;
var stage;

window.onload = function() {
var w = screen.width;
var h = screen.height;


stage = new PIXI.Container();
renderer = PIXI.autoDetectRenderer(w, h);
document.body.appendChild(renderer.view);
}

Please suggest a good solution to this problem. Do I need to calculate the scale of all the elements that are on the stage myself?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question