Wednesday, May 23, 2012

Corona에서 retina display 사용하는 법

config.lua 에 다음과 같이 넣는다.
 application = {  
      content = {  
           width = 320,  
           height = 480,   
           scale = "letterBox",  
           fps = 60,  
   
           imageSuffix = {  
       ["@1-5"] = 1.5, -- for Droid, Nexus One, etc.  
       ["@2x"] = 2,  -- for iPhone, iPod touch, iPad1, and iPad2  
       ["@3x"] = 3,  -- for various mid-size Android tablets  
       ["@4x"] = 4,  -- for iPad 3  
           }  
      }  
 }  
main.lua 에 다음과 같이 써준다.
 local red = display.newImageRect("red.png", 57, 63)  --> 57 x 63 은 이미지 사이즈
 red:setReferencePoint(display.TopLeftReferencePoint); --> pivot을 중앙이 아닌 좌상단으로(안해줘도 무관)
 red.x = 0  
 red.y = 0  
코드에는 image.png 를 로딩하는 걸로 했지만 시뮬레이터를 iPhone 4 로 돌리면 알아서 image@2x.png 가 로딩된다.
레퍼런스 :
Corona SDK: 03 Retina Images
Dynamic Image Resolution Made Easy
Content Scaling Made Easy
enabling retina display mode in corona sdk

Sprite Sheet의 경우
Sprite Sheet의 경우 위의 방식이 안되는데 다음과 같이 해결하는 방법이 있다.
Dynamic Retina SpriteSheets? Here's how!
I have to say I'm extremely pleased with the update if just because I can now finally add retina spritesheets to my game and thus having complete support for highres displays! Since I'm using even spaced SpriteSheets it was easy to do. If you're using custom sizes it should still be possible, but you're on your own.

No comments:

Post a Comment