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
| display.setStatusBar(display.HiddenStatusBar)
local displayGroup = display.newGroup()
local background = display.newImageRect("portrait.png", 320, 480)
displayGroup:insert(background)
background.x = display.contentWidth / 2
background.y = display.contentHeight / 2
local circle1 = display.newCircle(50, 50, 30)
circle1.x = 50
circle1.y = 50
circle1:setFillColor(0, 255, 255)
displayGroup:insert(circle1)
local circle2 = display.newCircle(50, 50, 30)
circle2.x = display.contentWidth - 50
circle2.y = 50
circle2:setFillColor(255, 0, 255)
displayGroup:insert(circle2)
local circle3 = display.newCircle(50, displayGroup.height - 50, 30)
circle3:setFillColor(255, 255, 0)
displayGroup:insert(circle3)
local circle4 = display.newCircle(displayGroup.width - 50, displayGroup.height - 50, 30)
circle4:setFillColor(0, 0, 0)
displayGroup:insert(circle4)
Runtime:addEventListener("orientation", function(event)
print("Orientation changed to: " .. event.type)
print("event.delta = " .. event.delta)
if event.type == "portrait" then
background:removeSelf()
background = display.newImageRect("portrait.png", 320, 480)
displayGroup:insert(background)
background:toBack()
elseif event.type == "portraitUpsideDown" then
background:removeSelf()
background = display.newImageRect("portraitUpsideDown.png", 320, 480)
displayGroup:insert(background)
background:toBack()
elseif event.type == "landscapeRight" then
background:removeSelf()
background = display.newImageRect("landscapeRight.png", 480, 320)
displayGroup:insert(background)
background:toBack()
elseif event.type == "landscapeLeft" then
background:removeSelf()
background = display.newImageRect("landscapeLeft.png", 480, 320)
displayGroup:insert(background)
background:toBack()
end
circle1:removeSelf()
circle2:removeSelf()
circle3:removeSelf()
circle4:removeSelf()
circle1 = display.newCircle(0, 0, 30)
circle1.x = 50
circle1.y = 50
circle1:setFillColor(0, 255, 255)
displayGroup:insert(circle1)
circle2 = display.newCircle(0, 0, 30)
circle2.x = display.contentWidth - 50
circle2.y = 50
circle2:setFillColor(255, 0, 255)
displayGroup:insert(circle2)
circle3 = display.newCircle(0, 0, 30)
circle3.x = 50
circle3.y = display.contentHeight - 50
circle3:setFillColor(255, 255, 0)
displayGroup:insert(circle3)
circle4 = display.newCircle(0, 0, 30)
circle4.x = display.contentWidth - 50
circle4.y = display.contentHeight - 50
circle4:setFillColor(0, 0, 0)
displayGroup:insert(circle4)
background.x = display.contentWidth / 2
background.y = display.contentHeight / 2
end) |