SlideShare una empresa de Scribd logo
1 de 24
Resolution in game
developing
iPhone game with cocos2d
Table of Contents
IOS family
Resolution in Cocos2d-iphone
Resolution in Cocos2d-x
・Design resolution
・Resolution policy
・Content scale factor
・Resolution policy advice
IOS family
Type Screen size (pixel)
iPhone 480, 320
iPhone Retina 960, 640
iPhone 5 1136, 640
iPad 1024, 768
iPad Retina 2048, 1536
Cocos2d-iphone
IOS family
Resolution in Cocos2d-iphone
Resolution in Cocos2d-x
・Design resolution
・Resolution policy
・Content scale factor
・Resolution policy advice
Resolution in cocos2d-
iPhone
Type Screen size
(pixel)
Point size in
cocos2d
(point)
Scale
factor
iPhone 480, 320 480, 320 1
iPhone
Retina
960, 640 480, 320 2
iPhone 5 1136, 640 568, 320 2
iPad 1024, 768 1024, 768 1
iPad
Retina
2048, 1536 1024, 768 2
One image for all devices?
For example:
image size: (1136, 640)  For iPhone 5
Is it available for iPhone retina?
YES!
CCSprite *sprite = [CCSprite
spriteWithFile:@"bg_town.png"];
CGSize winsize = [[CCDirector sharedDirector] winSize];
sprite.position = ccp(winsize.width / 2, winsize.height / 2);
[self addChild:sprite];
Center aligned
Is it available for iPhone 3GS?
NO!
If set sprite.scale = 0.5f;
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
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)
Table of Contents
IOS family
Resolution in Cocos2d-iphone
Resolution in Cocos2d-x
・Design resolution
・Resolution policy
・Content scale factor
・Resolution policy advice
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!
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.
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.
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)
Content Scale factor
CCDirector::sharedDirector() ->
setContentScaleFactor(scaleFactor)
Scale factor define the ratio of image size to
resolution size.
Example
Image: (1136, 640)
-> For iPhone 5
Target
Device: iPad (1024, 768)
Resolution size(Point size): (480, 320)
scaleFactor = 1024.0 / 480 = 2.13
Policy: kResolutionExactFit
1136
768
1024
721
(1136 / scaleFactor ,
640 / scaleFactor )
( (1136 / scaleFactor ) * (1024.0 / 48
(640 / scaleFactor ) * (768.0 / 320) )
->
(1136, 721)
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.
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.
Resolution Policy Advice 3
kResolutionShowAll
The whole point size is available in the screen.
Will have black belt in horizontal or vertical
direction
Thank you!

Más contenido relacionado

Similar a Resolution in cocos2d family

Tech Talk July 29 - Pixel
Tech Talk July 29 - Pixel Tech Talk July 29 - Pixel
Tech Talk July 29 - Pixel Indosystem
 
Supporting multi screen in android cn
Supporting multi screen in android cnSupporting multi screen in android cn
Supporting multi screen in android cnrffffffff007
 
Desigining for auto_layout
Desigining for auto_layoutDesigining for auto_layout
Desigining for auto_layoutJosh Burton
 
Lumia App Labs #17: Optimising your Nokia Lumia apps for large screen phones
Lumia App Labs #17: Optimising your Nokia Lumia apps for large screen phonesLumia App Labs #17: Optimising your Nokia Lumia apps for large screen phones
Lumia App Labs #17: Optimising your Nokia Lumia apps for large screen phonesLucian Tomuța
 
Idiot's Guide to viewport and pixel
Idiot's Guide to viewport and pixelIdiot's Guide to viewport and pixel
Idiot's Guide to viewport and pixelNathan Campos
 
Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐imShining @DevCamp
 
Developing AIR for Mobile with Flash Professional CS5.5
Developing AIR for Mobile with Flash Professional CS5.5Developing AIR for Mobile with Flash Professional CS5.5
Developing AIR for Mobile with Flash Professional CS5.5Chris Griffith
 
Tk2323 lecture 2 ui
Tk2323 lecture 2   uiTk2323 lecture 2   ui
Tk2323 lecture 2 uiMengChun Lam
 
3dsmaxdesign 2010 using_autodesk_revit_files00
3dsmaxdesign 2010 using_autodesk_revit_files003dsmaxdesign 2010 using_autodesk_revit_files00
3dsmaxdesign 2010 using_autodesk_revit_files00An Nam Education
 
Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2dVinsol
 
High DPI for desktop applications
High DPI for desktop applicationsHigh DPI for desktop applications
High DPI for desktop applicationsKirill Grouchnikov
 
Niels Leenheer - Weird browsers - code.talks 2015
Niels Leenheer - Weird browsers - code.talks 2015Niels Leenheer - Weird browsers - code.talks 2015
Niels Leenheer - Weird browsers - code.talks 2015AboutYouGmbH
 
Responsive & Adaptive Design @mLearnCon15 Nick Floro
Responsive & Adaptive Design @mLearnCon15 Nick FloroResponsive & Adaptive Design @mLearnCon15 Nick Floro
Responsive & Adaptive Design @mLearnCon15 Nick FloroNick Floro
 
Android training day 3
Android training day 3Android training day 3
Android training day 3Vivek Bhusal
 

Similar a Resolution in cocos2d family (20)

Tech Talk July 29 - Pixel
Tech Talk July 29 - Pixel Tech Talk July 29 - Pixel
Tech Talk July 29 - Pixel
 
Programmers guide
Programmers guideProgrammers guide
Programmers guide
 
Supporting multi screen in android cn
Supporting multi screen in android cnSupporting multi screen in android cn
Supporting multi screen in android cn
 
Desigining for auto_layout
Desigining for auto_layoutDesigining for auto_layout
Desigining for auto_layout
 
Lumia App Labs #17: Optimising your Nokia Lumia apps for large screen phones
Lumia App Labs #17: Optimising your Nokia Lumia apps for large screen phonesLumia App Labs #17: Optimising your Nokia Lumia apps for large screen phones
Lumia App Labs #17: Optimising your Nokia Lumia apps for large screen phones
 
Idiot's Guide to viewport and pixel
Idiot's Guide to viewport and pixelIdiot's Guide to viewport and pixel
Idiot's Guide to viewport and pixel
 
Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐
 
Google VR SDK 101
Google VR SDK 101Google VR SDK 101
Google VR SDK 101
 
Website Shortcut Graphics Recommendations
Website Shortcut Graphics RecommendationsWebsite Shortcut Graphics Recommendations
Website Shortcut Graphics Recommendations
 
Developing AIR for Mobile with Flash Professional CS5.5
Developing AIR for Mobile with Flash Professional CS5.5Developing AIR for Mobile with Flash Professional CS5.5
Developing AIR for Mobile with Flash Professional CS5.5
 
Tk2323 lecture 2 ui
Tk2323 lecture 2   uiTk2323 lecture 2   ui
Tk2323 lecture 2 ui
 
3dsmaxdesign 2010 using_autodesk_revit_files00
3dsmaxdesign 2010 using_autodesk_revit_files003dsmaxdesign 2010 using_autodesk_revit_files00
3dsmaxdesign 2010 using_autodesk_revit_files00
 
About Cocos2djs
About Cocos2djsAbout Cocos2djs
About Cocos2djs
 
Material design
Material designMaterial design
Material design
 
Cocos2d for beginners
Cocos2d for beginnersCocos2d for beginners
Cocos2d for beginners
 
Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2d
 
High DPI for desktop applications
High DPI for desktop applicationsHigh DPI for desktop applications
High DPI for desktop applications
 
Niels Leenheer - Weird browsers - code.talks 2015
Niels Leenheer - Weird browsers - code.talks 2015Niels Leenheer - Weird browsers - code.talks 2015
Niels Leenheer - Weird browsers - code.talks 2015
 
Responsive & Adaptive Design @mLearnCon15 Nick Floro
Responsive & Adaptive Design @mLearnCon15 Nick FloroResponsive & Adaptive Design @mLearnCon15 Nick Floro
Responsive & Adaptive Design @mLearnCon15 Nick Floro
 
Android training day 3
Android training day 3Android training day 3
Android training day 3
 

Último

Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 

Último (20)

Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 

Resolution in cocos2d family

  • 2. Table of Contents IOS family Resolution in Cocos2d-iphone Resolution in Cocos2d-x ・Design resolution ・Resolution policy ・Content scale factor ・Resolution policy advice
  • 3. IOS family Type Screen size (pixel) iPhone 480, 320 iPhone Retina 960, 640 iPhone 5 1136, 640 iPad 1024, 768 iPad Retina 2048, 1536
  • 4. Cocos2d-iphone IOS family Resolution in Cocos2d-iphone Resolution in Cocos2d-x ・Design resolution ・Resolution policy ・Content scale factor ・Resolution policy advice
  • 5. Resolution in cocos2d- iPhone Type Screen size (pixel) Point size in cocos2d (point) Scale factor iPhone 480, 320 480, 320 1 iPhone Retina 960, 640 480, 320 2 iPhone 5 1136, 640 568, 320 2 iPad 1024, 768 1024, 768 1 iPad Retina 2048, 1536 1024, 768 2
  • 6. One image for all devices? For example: image size: (1136, 640)  For iPhone 5
  • 7. Is it available for iPhone retina? YES! CCSprite *sprite = [CCSprite spriteWithFile:@"bg_town.png"]; CGSize winsize = [[CCDirector sharedDirector] winSize]; sprite.position = ccp(winsize.width / 2, winsize.height / 2); [self addChild:sprite];
  • 9. Is it available for iPhone 3GS? NO!
  • 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)
  • 18. Content Scale factor CCDirector::sharedDirector() -> setContentScaleFactor(scaleFactor) Scale factor define the ratio of image size to resolution size.
  • 19. Example Image: (1136, 640) -> For iPhone 5 Target Device: iPad (1024, 768) Resolution size(Point size): (480, 320)
  • 20. scaleFactor = 1024.0 / 480 = 2.13 Policy: kResolutionExactFit 1136 768 1024 721 (1136 / scaleFactor , 640 / scaleFactor ) ( (1136 / scaleFactor ) * (1024.0 / 48 (640 / scaleFactor ) * (768.0 / 320) ) -> (1136, 721)
  • 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