Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local stage = require "display".getCurrentStage()
- local typeface = native.newFont "American Typewriter"
- function splash(functions)
- local self = display.newGroup()
- local backdrop = display.newRect(self, 0, 0, stage.width, stage.height)
- backdrop:setFillColor(47, 47, 79)
- local actionCount = 0
- for _ in pairs(functions) do
- actionCount = actionCount + 1
- end
- local maxWidth = 0
- local height, pitch = stage.height * 0.1, stage.height * 0.12
- local yPos = (stage.height - (actionCount - 1 ) * pitch) / 2
- for text, action in pairs(functions) do
- local button = display.newGroup()
- self:insert(button)
- button.x, button.y = stage.width / 2, yPos
- yPos = yPos + pitch
- local label = display.newText(button, text, 0, 0, typeface, stage.height * 0.08)
- label:setTextColor(47, 47, 79)
- label.xOrigin, label.yOrigin = 0, 0
- maxWidth = math.max(maxWidth, label.width)
- button:addEventListener('tap', function(event) action(self) return true end)
- button:addEventListener('touch', function(event) return true end)
- end
- for i=2,self.numChildren do
- local button = self[i]
- local fill = display.newRect(button, 0, 0, maxWidth * 1.1, height)
- fill:setFillColor(.827 * 255, .694 * 255, .286 * 255)
- fill.xOrigin, fill.yOrigin = 0, 0
- fill:toBack()
- end
- self.isVisible = false
- return self
- end
- return splash
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement