Jump to content

Incorrect aspect ratio scaling when using DisplayObjectContainer.scale


ferahl
 Share

Recommended Posts

Hi,

 

I have begun making my game base from this: http://www.html5gamedevs.com/topic/1613-cocoonjs-webglrenderer-scaling-question/

 

I have chosen 576x1024 res based on: http://docs.gameclosure.com/guide/scaling.html

 

The original bunny demo runs at 800x600.

Here is my app code: https://github.com/DominicTobias/gamestarterjs/blob/master/app/app.js

 

When the bunny renders on 576x1024 it is stretched and it seems tilted too (becomes obvious when rotate is applied).

 

However when changing the app to 800x600 the bunny does not looked stretched (though when rotating it does look like it stretches slightly).

 

I've attached images, does someone have an idea why this is happening? Thanks!

Live demo showing issue: http://dominictobias.com/scalingissue/

(far right is from the 800x600 version)

post-6751-0-26339200-1392072945.png

post-6751-0-40805700-1392072945.png

post-6751-0-56632100-1392072945.png

Link to comment
Share on other sites

Nevermind, my bad - I blindly copied and pasted the code in the forum post link above but it wasn't setting the aspect ratio correctly. Fixed logic:
 

setupScene: function() {	this.isPortrait = window.innerHeight > window.innerWidth;	this.scene = new PIXI.DisplayObjectContainer();	if (this.isPortrait) {		// Portrait scaling		this.gameWidth = this.settings.appWidth;		this.gameHeight = window.innerHeight * (this.settings.appWidth / window.innerWidth);		this.gameScale = window.innerWidth / this.settings.appWidth;	} else {		// Landscape scaling		this.gameWidth = window.innerWidth * (this.settings.appHeight / window.innerHeight);		this.gameHeight = this.settings.appHeight;		this.gameScale = window.innerHeight / this.settings.appHeight;	}	this.scene.scale = new PIXI.Point(this.gameScale, this.gameScale);},

(https://github.com/DominicTobias/gamestarterjs/blob/master/app/app.js)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...