2011년 3월 4일 금요일

Corona SDK......02 - Sprite Animation

ㅎㅎ
게임에 있어서 가장 중요한 Sprite Animation ..

Corona SDK 는 두가지 방법을 지원한다.

하나는 일정한 크기의 타일(?) 방식의 Sprite Animation .
또 하나는 크기가 일정하지 않은 Sprite 를 연결해서 보여주는 방식.
( Sprite Sheets 방식 )

예를 보면 바로 이해 될듯. ㅋㅋ

크기가 일정한 Sprite.

크기가 일정 하지 않은 Sprite

크기가 일정한 Sprite 를 사용하는게 훨씬 쉽다.ㅡ,.ㅡ

require "sprite"  -- sprite 를 사용하기 위한 라이브러리(?) 추가
display.setStatusBar( display.HiddenStatusBar )  -- Status Bar 감추기

baseline = 280

-- sprite 객체(?) 이용하여 sheet2 를 생성하는데...
-- 파일 은 greenman 이고, 하나의 Sprite 타일이 128, 128 이다 라는 의미
local sheet2 = sprite.newSpriteSheet( "greenman.png", 128, 128 )

-- sprite 객체(?)인 sheet2 를 이용해서 sprite set 생성
-- sprite 타일 갯수가 1 ~ 15 라는 의미
-- 타일의 순서는 
-- 1  2  3  4
-- 5  6  7  8
-- 9 10 11 12
-- 13 14 15

local spriteSet2 = sprite.newSpriteSet(sheet2, 1, 15)

-- sprireset 을 setting 한다.
-- man 은 sprite 이름 정도로 이해 하면...
-- 1 .. 15 를 200 ms 동안 재생.
-- 젤 뒤에 0 이 나름 중요한 것이다. 
-- 0 이면 무한 반복...
-- 1 보다 크면...숫자 만큼 반복.
-- -1 이면 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 ......3 2 1
-- 이렇게 반복. 됨.
sprite.add( spriteSet2, "man", 1, 15, 200, 0 )  

-- 화면에 출력하기 위한 instance 생성...
-- 및 위치 설정.
local instance2 = sprite.newSprite( spriteSet2 )
instance2.x = 3 * display.contentWidth / 4 + 30
instance2.y = baseline - 55

-- man 으로 설정 된 놈을 불러 오고....
instance2:prepare("man")
-- animation paly...
instance2:play()

sprite sheet 는 담 기회에...
이건 솔직히 어려운게 아니라 넘 손이 많이 간다.ㅡ,.ㅡ



2011년 3월 2일 수요일

Corona SDK......01 - Hello World

Corona SDK 는 기본적으로 두개의 파일이 필요 한듯..

config.lua -> 화명 해상도 등 설정 파일인듯...
main.lua -> 이건 이름이 달라도 상관 없는듯...

config.lua 내용

-- config.lua

application =
{
content =
{
width = 320,  -- 가로 해상도
height = 480,  -- 세로 해상도
scale = "zoomEven" -- zoom to fill screen, possibly cropping edges
},
}

Scale 는

  • "none" - turns off dynamic content scaling
    : Content 와 Sacle 를 무시(?)
  • "letterbox" - uniformly scales up content as much as possible, while still showing all content on the screen. This is similar to watching a widescreen DVD on a non-widescreen TV set, except that you can use offstage content to fill the "bleed" areas rather than displaying black bars.
    : 대충 봐서는...Content 를 가능한 최대로 표시 한다는 옵션.
    : 마치 DVD 영화를 TV 에서 보면 아래 위가 검은색으로 채워 지는것 같음.
       
  • "zoomEven" - uniformly scales up content to fill the screen, while preserving aspect ratio. Some content may appear offscreen, if the new screen has a different aspect ratio
    : 가로 세로 비율을 유지하면서 스크린에 내용 채우기.
  • "zoomStretch" - non-uniformly scales up content to fill the screen. All content will remain onscreen, but it may be stretched vertically or horizontally.
    : 비율을 유지 하지 않고 스크린에 맞게 내용 채우기.
    : 가로 / 세로 한쪽을 길어져서 보일 수 있음. 

실제 게임을 만들기 위해서는 별다른 차이가 없어 보임. ( 현재까지는.. )

main.lua


local textObject = display.newText( "Hello World!", 50, 50, native.systemFont, 124 )
-- 화면에 Text 박스(?) 를 생성함.
-- display.newText Text 박스를 생성하는 Function 정도(?)
textObject:setTextColor( 255,255,255 )
-- Text 박스의 색 지정.

** display : displayObject 를 생성 할때 사용 하는놈..
Image 를 만들고 싶어면...
local image = display.newImage("xxx.png")

이렇게 해서 생성 할 수 있음.