Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function scene:create( event )
- math.randomseed(os.time())
- local sceneGroup = self.view
- generatePassword(2)
- local buttonlist = {}
- local code = {}
- local drawCode = display.newText({text = "",x = 50,y = 50})
- local tryCount = 0
- local drawTryCount = display.newText({text = "Nombre d'essai : 0",x = display.contentHeight/2,y = display.contentWidth /5,align = "right" })
- local money = 0
- local drawMoney = display.newText({text = "money : 0",x = display.contentHeight/2,y = display.contentWidth /4 ,align = "right"})
- local function onButton(event)
- if event.target.id == "10" then
- local str = ""
- for i = 1,#code do
- str = str..code[i]
- end
- print("try "..str)
- if #str ~= 0 then
- if str == password then
- print("correct")
- else
- print("false")
- tryCount = tryCount +1
- drawTryCount.text = "Nombre d'essai : "..tryCount
- end
- end
- code = {}
- drawCode.text = ""
- elseif event.target.id == "11" then
- code = {}
- drawCode.text = ""
- else
- table.insert(code,event.target.id)
- local str = ""
- for i = 1,#code do
- str = str..code[i]
- end
- drawCode.text = str
- end
- end
- local function buyStuff()
- composer.gotoScene("shop")
- end
- print("creategamescene")
- table.insert(buttonlist, widget.newButton({
- label = "1",
- id = "1",
- x = display.contentWidth/10,
- y = display.contentHeight/5,
- shape = "circle",
- radius = 15,
- fillColor = { default={ 1, 1, 1, 1 }, over={ 0, 1, 0, 1 } },
- onRelease = onButton
- }))
- table.insert(buttonlist, widget.newButton({
- label = "2",
- id = "2",
- x = display.contentWidth/10+40,
- y = display.contentHeight/5,
- shape = "circle",
- radius = 15,
- fillColor = { default={ 1, 1, 1, 1 }, over={ 0, 1, 0, 1 } },
- onRelease = onButton
- }))
- table.insert(buttonlist, widget.newButton({
- label = "3",
- id = "3",
- x = display.contentWidth/10+80,
- y = display.contentHeight/5,
- shape = "circle",
- radius = 15,
- fillColor = { default={ 1, 1, 1, 1 }, over={ 0, 1, 0, 1 } },
- onRelease = onButton
- }))
- table.insert(buttonlist, widget.newButton({
- label = "4",
- id = "4",
- x = display.contentWidth/10,
- y = display.contentHeight/5 +40,
- shape = "circle",
- radius = 15,
- fillColor = { default={ 1, 1, 1, 1 }, over={ 0, 1, 0, 1 } },
- onRelease = onButton
- }))
- table.insert(buttonlist, widget.newButton({
- label = "5",
- id = "5",
- x = display.contentWidth/10+40,
- y = display.contentHeight/5 +40,
- shape = "circle",
- radius = 15,
- fillColor = { default={ 1, 1, 1, 1 }, over={ 0, 1, 0, 1 } },
- onRelease = onButton
- }))
- table.insert(buttonlist, widget.newButton({
- label = "6",
- id = "6",
- x = display.contentWidth/10+80,
- y = display.contentHeight/5 +40,
- shape = "circle",
- radius = 15,
- fillColor = { default={ 1, 1, 1, 1 }, over={ 0, 1, 0, 1 } },
- onRelease = onButton
- }))
- table.insert(buttonlist, widget.newButton({
- label = "7",
- id = "7",
- x = display.contentWidth/10,
- y = display.contentHeight/5 +80,
- shape = "circle",
- radius = 15,
- fillColor = { default={ 1, 1, 1, 1 }, over={ 0, 1, 0, 1 } },
- onRelease = onButton
- }))
- table.insert(buttonlist, widget.newButton({
- label = "8",
- id = "8",
- x = display.contentWidth/10+40,
- y = display.contentHeight/5 +80,
- shape = "circle",
- radius = 15,
- fillColor = { default={ 1, 1, 1, 1 }, over={ 0, 1, 0, 1 } },
- onRelease = onButton
- }))
- table.insert(buttonlist, widget.newButton({
- label = "9",
- id = "9",
- x = display.contentWidth/10+80,
- y = display.contentHeight/5 +80,
- shape = "circle",
- radius = 15,
- fillColor = { default={ 1, 1, 1, 1 }, over={ 0, 1, 0, 1 } },
- onRelease = onButton
- }))
- table.insert(buttonlist, widget.newButton({
- label = "0",
- id = "0",
- x = display.contentWidth/10+40,
- y = display.contentHeight/5 +120,
- shape = "circle",
- radius = 15,
- fillColor = { default={ 1, 1, 1, 1 }, over={ 0, 1, 0, 1 } },
- onRelease = onButton
- }))
- table.insert(buttonlist, widget.newButton({
- label = "ok",
- id = "10",
- x = display.contentWidth/10+80,
- y = display.contentHeight/5 +120,
- shape = "circle",
- radius = 15,
- fillColor = { default={ 1, 1, 1, 1 }, over={ 0, 1, 0, 1 } },
- onRelease = onButton
- }))
- table.insert(buttonlist, widget.newButton({
- label = "clear",
- id = "11",
- x = display.contentWidth/10,
- y = display.contentHeight/5 +120,
- shape = "circle",
- radius = 15,
- fillColor = { default={ 1, 1, 1, 1 }, over={ 0, 1, 0, 1 } },
- onRelease = onButton
- }))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement