-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtabScreen.lua
More file actions
140 lines (115 loc) · 3.18 KB
/
tabScreen.lua
File metadata and controls
140 lines (115 loc) · 3.18 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
136
137
138
139
140
module(..., package.seeall)
--====================================================================--
-- SCENE: TAB SCREEN
--====================================================================--
--[[
- Version: [1.0]
- Made by: tsengvn
- Mail: nmhien88@gmail.com
******************
- INFORMATION
******************
--]]
--mainView, tabView, currentScreen, tabBar
new = function ()
------------------
-- Groups
------------------
local localGroup = display.newGroup()
-- begin create screen
-- tabs = widget.newTabBar{
-- top=430,
-- buttons=tabButtons
-- }
init()
--localGroup:insert(mainView)
-- end create screen
return mainView
end
function init()
--Create a group that contains the entire screen and tab bar
mainView = display.newGroup()
--Create a group that contains the screens beneath the tab bar
tabView = display.newGroup()
mainView:insert(tabView)
loadScreen("shopScreen")
tabBar = viewController.newTabBar{
tabs = {"", "", "", "", ""},
onRelease = showScreen,
default = {"images/tab_fishing.png", "images/tab_shop.png","images/tab_champions.png","images/tab_treasure.png","images/tab_diary.png"},
over = {"images/tab_fishing_selected.png","images/tab_shop_selected.png","images/tab_champions_selected.png","images/tab_treasure_selected.png","images/tab_diary_selected.png"}
}
mainView:insert(tabBar)
tabBar.selected()
return true
end
function loadScreen(newScreen)
if currentScreen then
currentScreen:cleanUp()
end
currentScreen = require(newScreen).new()
tabView:insert(currentScreen)
return true
end
function showScreen(event)
local t = event.target
local phase = event.phase
print ("id " .. t.id)
if phase == "ended" then
if t.id == 1 then
loadScreen("shopScreen")
elseif t.id == 2 then
loadScreen("shopScreen")
elseif t.id == 3 then
loadScreen("shopScreen")
elseif t.id == 4 then
loadScreen("shopScreen")
elseif t.id == 5 then
loadScreen("shopScreen")
end
tabBar.selected(t)
end
return true
end
-- local function onBtnPress( event )
-- print( "You pressed tab button: " .. event.target.id )
-- end
--
-- tabButtons = {
-- {
-- up = "images/tab_fishing.png",
-- down = "images/tab_fishing_selected.png",
-- width = 50,
-- height = 50 ,
-- onPress = onBtnPress,
-- selected = true
-- },
-- {
-- up = "images/tab_shop.png",
-- down = "images/tab_shop_selected.png",
-- width = 32,
-- height = 32,
-- onPress = onBtnPress,
-- },
-- {
-- up = "images/tab_champions.png",
-- down = "images/tab_champions_selected.png",
-- width = 32,
-- height = 32,
-- onPress = onBtnPress,
-- },
-- {
-- up = "images/tab_treasure.png",
-- down = "images/tab_treasure_selected.png",
-- width = 32,
-- height = 32,
-- onPress = onBtnPress,
-- },
-- {
-- up = "images/tab_diary.png",
-- down = "images/tab_diary_selected.png",
-- width = 32,
-- height = 32,
-- onPress = onBtnPress,
-- }
-- }