Jump to content

Resolution-independent games


IvanK
 Share

Recommended Posts

Thank you very much!

Interesting, your code does basically the same as what I already had in place.

This is helpful because it means I must have just made an error somewhere - at least now I can be confident that the approach I am using is valid!

Thanks a lot for your help.

I didn't say that it was working, I only said that's what I'm using :P

Link to comment
Share on other sites

Well nevertheless it helped for me to see your code!

Here's my new resize method:

 

function resizeGame() {	var gameArea = document.getElementById('game');	var windowW = window.innerWidth;	var windowH = window.innerHeight;	var dstW = windowW;	var dstH = windowH;	var aspectRatio =  statics.STAGE_W / statics.STAGE_H;	var w = dstW;	var h = dstH;	if (dstW > aspectRatio * dstH) {		w = Math.ceil(aspectRatio * dstH);	} else {		h = Math.ceil(dstW / aspectRatio);	}	var x = w * -0.5;	var y = h * -0.5;	//	gameArea.style.width = '' + w + 'px';	gameArea.style.height = '' + h + 'px';	//	gameArea.style.marginLeft = '' + x + 'px';	gameArea.style.marginTop = '' + y + 'px';	//	screens.screenManager.resize(w,h);}

 

I tested it on an iPad1 running iOS5 and an iPad mini running iOS6 and it worked perfectly on both of them.

I'm running the method after a setTimeout on load with a delay of 1 sec, also on orientationchanged an on window resize.

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...