ferahl Posted February 10, 2014 Share Posted February 10, 2014 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) Quote Link to comment Share on other sites More sharing options...
ferahl Posted February 11, 2014 Author Share Posted February 11, 2014 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) Quote Link to comment Share on other sites More sharing options...
xerver Posted February 11, 2014 Share Posted February 11, 2014 Don't create a new point object each time:this.scene.scale.set(this.gameScale, this.gameScale);Save you a gc cycle or two 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.