
파일명: main.lua
local centerX = display.contentCenterX
local centerY = display.contentCenterY
local text1,button
text1 = display.newText( "INTRO", centerX, 50, native.systemFontBold, 24 )
text1:setFillColor( 1,1,1 )
button = display.newImage( "plane.png" )
button.x = display.contentWidth / 2
button.y = display.contentHeight/ 2
이제 버튼을 클릭하면 글씨의 색이 변하도록 해봅니다.
button:addEventListener( "tap", button )
function button:tap( event )
local r = math.random()
local g = math.random()
local b = math.random()
text1:setFillColor( r, g, b )
end
위의 그림처럼 이미지를 클릭하면 글씨의 색이 변하게됩니다.