Friday, April 27, 2012

Sprite Sheet 데이터를 로드하는 코드

myTest.lua 에서 Sprite Sheet 데이터를 로드하는 코드
 local mySpriteSheet = sprite.newSpriteSheetFromData("myTest.png", require("myTest").getSpriteSheetData() )  

myTest.lua 의 내용 (Zwoptex 에서 생성)
 module(...)  
 -- This file is for use with CoronaSDK™ and was generated by Zwoptex (http://zwoptexapp.com/)  
 --  
 -- For more details, see http://developer.anscamobile.com/reference/sprite-sheets  
 function getSpriteSheetData()  
      local sheet = {  
           frames = {  
                {  
                     name = "myTest-1.png",  
                     spriteColorRect = { x = 20, y = 38, width = 101, height = 157 },   
                     textureRect = { x = 165, y = 159, width = 101, height = 157 },   
                     spriteSourceSize = { width = 181, height = 209 },   
                     spriteTrimmed = true,  
                     textureRotated = false  
                },  
                {  
                     name = "myTest-2.png",  
                     spriteColorRect = { x = 16, y = 52, width = 79, height = 157 },   
                     textureRect = { x = 0, y = 187, width = 79, height = 157 },   
                     spriteSourceSize = { width = 181, height = 209 },   
                     spriteTrimmed = true,  
                     textureRotated = false  
                },  
                {  
                     name = "myTest-3.png",  
                     spriteColorRect = { x = 5, y = 52, width = 107, height = 157 },   
                     textureRect = { x = 165, y = 0, width = 107, height = 157 },   
                     spriteSourceSize = { width = 181, height = 209 },   
                     spriteTrimmed = true,  
                     textureRotated = false  
                },  
                {  
                     name = "myTest-4.png",  
                     spriteColorRect = { x = 18, y = 9, width = 163, height = 185 },   
                     textureRect = { x = 0, y = 0, width = 163, height = 185 },   
                     spriteSourceSize = { width = 181, height = 209 },   
                     spriteTrimmed = true,  
                     textureRotated = false  
                },  
           }  
      }  
      return sheet  
 end  
관련링크 : Corona로 Sprite Sheet Animation 만들기

No comments:

Post a Comment