-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindowResizer.lua
More file actions
68 lines (55 loc) · 1.22 KB
/
windowResizer.lua
File metadata and controls
68 lines (55 loc) · 1.22 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
local m = {}
function m:new()
local windowSize = require("windowSize")
local sizeTxt
local function onBrowserResize()
local win = windowSize.getSize()
for prop, val in pairs(win) do
sizeTxt[prop].text = prop..': '..val
end
end
Runtime:addEventListener( "resize", onBrowserResize )
--#############################################################################
--# UI
--#############################################################################
local cx = display.contentCenterX
local cy = display.contentCenterY
local font = native.systemFont
local newText = display.newText
--# Title
local title = newText({
text = "Resize your browser window",
x = cx,
y = 40,
font = font,
fontSize = 18
})
title:setFillColor(0.97,0.48,0)
--# Sizes
local sizeLbls = {
'innerWidth',
'innerHeight',
'outerWidth',
'outerHeight',
'screenLeft',
'screenTop'
}
sizeTxt = {}
for i=1, #sizeLbls do
local txt = newText({
text = sizeLbls[i]..': 0',
x = cx,
y = (26*i) + 60,
font = font,
fontSize = 12
})
sizeTxt[sizeLbls[i]] = txt
end
--# Init Values
if system.getInfo('platform') == 'html5' then
onBrowserResize()
else
title.text = "Please run in a browser"
end
end
return m