-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstarsView.lua
More file actions
135 lines (121 loc) · 3.62 KB
/
starsView.lua
File metadata and controls
135 lines (121 loc) · 3.62 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
local widget = require("widget")
local starView = {}
local starInitX = 100
local starInitY = 0
local starValue = 0
local btnEditable = true
function starView:new(x, y, initStarNumber, editable)
starInitX = x
starInitY = y
btnEditable = editable
function starIndicator(starNumber)
starValue = starNumber
print("starNumber: "..starNumber)
if(starNumber == 0) then
starView.star1.alpha = 0.4; starView.star2.alpha = 0.4; starView.star3.alpha = 0.4; starView.star4.alpha = 0.4; starView.star5.alpha = 0.4;
elseif(starNumber == 1) then
starView.star1.alpha = 1; starView.star2.alpha = 0.4; starView.star3.alpha = 0.4; starView.star4.alpha = 0.4; starView.star5.alpha = 0.4;
elseif(starNumber == 2) then
starView.star1.alpha = 1; starView.star2.alpha = 1; starView.star3.alpha = 0.4; starView.star4.alpha = 0.4; starView.star5.alpha = 0.4;
elseif(starNumber == 3) then
starView.star1.alpha = 1; starView.star2.alpha = 1; starView.star3.alpha = 1; starView.star4.alpha = 0.4; starView.star5.alpha = 0.4;
elseif(starNumber == 4) then
starView.star1.alpha = 1; starView.star2.alpha = 1; starView.star3.alpha = 1; starView.star4.alpha = 1; starView.star5.alpha = 0.4;
else
starView.star1.alpha = 1; starView.star2.alpha = 1; starView.star3.alpha = 1; starView.star4.alpha = 1; starView.star5.alpha = 1;
end
end
function onStarButtonRelease(event)
local btId = event.target.id
-- print(btId)
if(btnEditable == false) then
return 0
end
if(btId == "star1") then
starIndicator(1)
elseif(btId == "star2") then
starIndicator(2)
elseif(btId == "star3") then
starIndicator(3)
elseif(btId == "star4") then
starIndicator(4)
else
starIndicator(5)
end
end
starView.star1 = widget.newButton{
id = "star1",
default = "star.png",
over = "star.png",
left = starInitX + 0,
top = starInitY,
width = 48, height = 48,
-- label = "",
-- top=topBoundary,
-- bottom=bottomBoundary,
-- yOffset = 30,
onRelease = onStarButtonRelease
}
starView.star1.alpha = 0.4
starView.star2 = widget.newButton{
id = "star2",
default = "star.png",
over = "star.png",
left = starInitX + 50,
top = starInitY,
width = 48, height = 48,
-- label = "",
-- top=topBoundary,
-- bottom=bottomBoundary,
-- yOffset = 30,
onRelease = onStarButtonRelease
}
starView.star2.alpha = 0.4
starView.star3 = widget.newButton{
id = "star3",
default = "star.png",
over = "star.png",
left = starInitX + 100,
top = starInitY,
width = 48, height = 48,
-- label = "",
-- top=topBoundary,
-- bottom=bottomBoundary,
-- yOffset = 30,
onRelease = onStarButtonRelease
}
starView.star3.alpha = 0.4
starView.star4 = widget.newButton{
id = "star4",
default = "star.png",
over = "star.png",
left = starInitX + 150,
top = starInitY,
width = 48, height = 48,
-- label = "",
-- top=topBoundary,
-- bottom=bottomBoundary,
-- yOffset = 30,
onRelease = onStarButtonRelease
}
starView.star4.alpha = 0.4
starView.star5 = widget.newButton{
id = "star5",
default = "star.png",
over = "star.png",
left = starInitX + 200,
top = starInitY,
width = 48, height = 48,
-- label = "",
-- top=topBoundary,
-- bottom=bottomBoundary,
-- yOffset = 30,
onRelease = onStarButtonRelease
}
starView.star5.alpha = 0.4
starIndicator(initStarNumber)
end
function starView:getStarValue()
return starValue
end
return starView