In JavaScript, screen.width reports 320 on my previous generation iPod touch. On an iPhone 4 it also reports 320. I thought the new iPhone 4 "retina" display was more? Why would it r开发者_JAVA技巧eport 320?
The screen is treated as an "Extra high resolution" 320 pixel for most purposes. Even though literally it has more pixels.
(Not web-page, but informatively: Old pre-retina apps run, the same, but sneakily load the specially named double-resolution images, if they're found. (image.png vs image@2x.png for example.) And drawing commands work as if it was 320 pixels.)
This is just an assumption, you may get this because the physical pixels is "hidden" from the user which. So 320, does not mean 320pixels but 320 points, an relative size. 1 point maps to 1px on the "old" iPhone, but 1 point maps to 2pixels on the new Retina screen. Again, just an assumption....
Best approach to getting a value that makes sense seems to be doing:
var dpr = Math.ceil(window.devicePixelRatio);
var actualSize = cc.size(screen.height*dpr, screen.width*dpr);
精彩评论