-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview07Number.lua
More file actions
168 lines (131 loc) ยท 4.37 KB
/
Copy pathview07Number.lua
File metadata and controls
168 lines (131 loc) ยท 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
--ํ๋๋ง์ ์นด๋ ๊ฒ์
local composer = require( "composer" )
local scene = composer.newScene()
function scene:create( event )
local sceneGroup = self.view
-- ๋ฐฐ๊ฒฝ ์ค์
local background = display.newImageRect("์ด๋ฏธ์ง/๋ฏธ๋๊ฒ์/๋ฏธ๋๊ฒ์_ํ๋๋ง์/๋ฏธ๋๊ฒ์_์ซ์๊ฒ์ ๋ฐฐ๊ฒฝ(ํ๋๋ง์).png",display.contentWidth, display.contentHeight)
background.x, background.y = display.contentWidth/2, display.contentHeight/2
sceneGroup:insert( background )
--ํ์ด๋จธ์ ์ฝ์ธ ๊ทธ๋ฆผ--
local time = display.newImageRect("์ด๋ฏธ์ง/๋ฏธ๋๊ฒ์/๋ฏธ๋๊ฒ์_์๊ฐํ์ด๋จธ.png", display.contentWidth/7.91, display.contentHeight/3.78)
time.anchorX, time.anchorY =0,0
time.x,time.y = display.contentWidth/1.180, display.contentHeight/21.53
sceneGroup:insert(time)
local limit = 15
local showLimit = display.newText(limit,display.contentWidth/1.1,display.contentHeight/5.555,"font/์ํ๋ฆฌ๋์ค๋ Medium.ttf")
showLimit:setFillColor(1,0,0)
showLimit.size = 80
sceneGroup:insert(showLimit)
--์นด๋ ์์ฑ
local cards = { }
local cardGroup = display.newGroup()
for i = 1, 16 do
cards[i] = 0
end
currentNum = 1
--์นด๋ ํด๋ฆญ์
local function click( event )
if event.target.id == 16 and event.target.id == currentNum then
timer.cancelAll()
if limit > 10 then
composer.setVariable("score2", 15)
else
composer.setVariable("score2", 10)
end
composer.removeScene("view07Number")
composer.gotoScene("view08Number")
elseif event.target.id == currentNum then
display.remove(event.target)
currentNum = currentNum + 1
end
end
--์นด๋์ ์ด๋ฏธ์ง ๋ฐ ์์ด๋ ๋ถ์ฌ
for i = 1, 16 do
local card = display.newImage(cardGroup, "์ด๋ฏธ์ง/๋ฏธ๋๊ฒ์/๋ฏธ๋๊ฒ์_ํ๋๋ง์/๋ฏธ๋๊ฒ์_์ซ์๊ฒ์ ๊ตฌ์ฌ" .. i .. "(ํ๋๋ง์).png")
card:addEventListener("touch", click)
card.id = i
local looping = 1
while looping == 1 do
local num = math.random(1, 16)
if cards[num] == 0 then
cards[num] = card
looping = 0
end
end
end
--์นด๋ ์์น ์ค์
local startX, startY = display.contentWidth/2.3 , display.contentHeight/5.3
local currentX, currentY = startX, startY
for i = 1, 16 do
cards[i].x, cards[i].y = currentX, currentY
if i == 2 then
currentX = display.contentWidth/4.5
currentY = display.contentHeight/2.45
elseif i == 7 then
currentX = display.contentWidth/3.3
currentY = display.contentHeight/1.6
elseif i == 11 then
currentX = display.contentWidth/4.3
currentY = display.contentHeight/1.2
else
currentX = currentX + display.contentWidth/7.3988
end
end
sceneGroup:insert(cardGroup)
-- ์๊ฐ ์ ํ --
local function timeAttack( event )
limit = limit - 1
showLimit.text = limit
if limit == 0 then
composer.setVariable("score2", 5)
composer.removeScene("view07Number")
composer.gotoScene("view08Number")
end
end
timer.performWithDelay( 1500, timeAttack, 0)
end
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if phase == "will" then
-- Called when the scene is still off screen and is about to move on screen
elseif phase == "did" then
-- Called when the scene is now on screen
--
-- INSERT code here to make the scene come alive
-- e.g. start timers, begin animation, play audio, etc.
end
end
function scene:hide( event )
local sceneGroup = self.view
local phase = event.phase
if event.phase == "will" then
-- Called when the scene is on screen and is about to move off screen
--
-- INSERT code here to pause the scene
-- e.g. stop timers, stop animation, unload sounds, etc.)
elseif phase == "did" then
-- Called when the scene is now off screen
end
end
function scene:destroy( event )
local sceneGroup = self.view
-- Called prior to the removal of scene's "view" (sceneGroup)
--
-- INSERT code here to cleanup the scene
-- e.g. remove display objects, remove touch listeners, save state, etc.
end
local function catch( event )
if ( event.target.isFocus ) then
display.remove(event.target)
end
end
---------------------------------------------------------------------------------
-- Listener setup
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
-----------------------------------------------------------------------------------------
return scene