This document discusses resolution handling in Cocos2d game development. It describes the different resolutions of iOS devices and how to handle scaling images to support different resolutions in Cocos2d-iPhone and Cocos2d-x. In Cocos2d-iPhone, images are scaled by a scale factor based on the device, while in Cocos2d-x developers can set the design resolution and use different resolution policies to scale images. The document provides advice on which resolution policies to use for different scaling needs.
11. So we can use this
solution?
NO!
Reason: MEMORY!
Device Installed
Memory
Available
Memory
Memory
Warning
Threshold
First generation
Second
generation
128MB Around 30MB Around 20MB
iPhone 3GS
iPad
256MB Around 90MB Around 70MB
iPhone 4/4S
iPad 2
512MB Around
300MB
Around
250MB
12. Is it available for iPad?
Size of iPhone retina: (960, 640)
Size of iPad: (1024, 768)
Answer: NO!
Reason: Coordinator is different!
Coordinator of iPhone retina: (480, 320)
Coordinator of iPad: (1024, 768)
13. Table of Contents
IOS family
Resolution in Cocos2d-iphone
Resolution in Cocos2d-x
・Design resolution
・Resolution policy
・Content scale factor
・Resolution policy advice
14. Resolution in cocos2d-x
Type Screen size
(pixel)
Point size in
cocos2d
(point)
Scale
factor
iPhone 480, 320 ? ?
iPhone
Retina
960, 640 ? ?
iPhone 5 1136, 640 ? ?
iPad 1024, 768 ? ?
iPad
Retina
2048, 1536 ? ?
You can set point size and scale factor freely!
15. Design resolution size
CCEGLView::sharedOpenGLView() ->
setDesignResolutionSize(width, height, policy)
(width, height) is design resolution, i.e. point size.
policy defines the relationship between point size
and device screen size.
16. Resolution Policy in
cocos2d-x 1
scale_x = device_screen_size.width /
point_size.width
scale_y = device_screen_size.height /
point_size.height
scale: The scale ratio to scale image from
point size.
17. Resolution Policy in
cocos2d-x 2
kResolutionExactFit
In x axis, scale = scale_x
In y axis, scale = scale_y
kResolutionNoBorder
scale = max(scale_x, scale_y)
kResolutionShowAll
scale = min(scale_x, scale_y)
21. Resolution Policy Advice 1
kResolutionExactFix
The whole point size is available in the
screen.
The whole image will be shown in the
screen, but may appear stretched or
compressed.
Don’t choose this.
22. Resolution Policy Advice 2
kResolutionNoBorder
It is full screen. There is no black belt.
But not the whole point size is available in the
screen.
CCSize visibleOrigin =
CCDirector::sharedDirector()->getVisibleOrigin();
CCSize visibleSize =
CCDirector::sharedDirector()->getVisibleSize();
From visibleOrigin and visibleSize, you get the
rect that can be display in the screen.
23. Resolution Policy Advice 3
kResolutionShowAll
The whole point size is available in the screen.
Will have black belt in horizontal or vertical
direction