Commit 59174af6 59174af6308ab45c913210b0aa82b0f327435070 by jinwawa

0806

1 parent bfabb962
Showing 170 changed files with 3641 additions and 95 deletions
...@@ -36,7 +36,7 @@ function LoadingScene:onCreate() ...@@ -36,7 +36,7 @@ function LoadingScene:onCreate()
36 end 36 end
37 37
38 self:addChild(self.ui); 38 self:addChild(self.ui);
39 39 --logD("LoadingScene------------->"..display.width);
40 self.ui:setContentSize(cc.size(display.width,display.height)); 40 self.ui:setContentSize(cc.size(display.width,display.height));
41 ccui.Helper:doLayout(self.ui); 41 ccui.Helper:doLayout(self.ui);
42 42
......
1 {
2 "init_cfg": {
3 "isLandscape": true,
4 "isWindowTop": false,
5 "name": "rubbish",
6 "width": 960,
7 "height": 640,
8 "entry": "src/main.lua",
9 "consolePort": 6050,
10 "uploadPort": 6060
11 },
12 "simulator_screen_size": [
13 {
14 "title": "iPhone 3Gs (480x320)",
15 "width": 480,
16 "height": 320
17 },
18 {
19 "title": "iPhone 4 (960x640)",
20 "width": 960,
21 "height": 640
22 },
23 {
24 "title": "iPhone 5 (1136x640)",
25 "width": 1136,
26 "height": 640
27 },
28 {
29 "title": "iPad (1024x768)",
30 "width": 1024,
31 "height": 768
32 },
33 {
34 "title": "iPad Retina (2048x1536)",
35 "width": 2048,
36 "height": 1536
37 },
38 {
39 "title": "Android (800x480)",
40 "width": 800,
41 "height": 480
42 },
43 {
44 "title": "Android (854x480)",
45 "width": 854,
46 "height": 480
47 },
48 {
49 "title": "Android (1280x720)",
50 "width": 1280,
51 "height": 720
52 },
53 {
54 "title": "Android (1920x1080)",
55 "width": 1920,
56 "height": 1080
57 }
58 ]
59 }
...\ No newline at end of file ...\ No newline at end of file
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3 <plist version="1.0">
4 <dict>
5 <key>frames</key>
6 <dict>
7 <key>defaultarmature1.png</key>
8 <dict>
9 <key>width</key>
10 <integer>20</integer>
11 <key>height</key>
12 <integer>32</integer>
13 <key>originalWidth</key>
14 <integer>20</integer>
15 <key>originalHeight</key>
16 <integer>32</integer>
17 <key>x</key>
18 <integer>0</integer>
19 <key>y</key>
20 <integer>0</integer>
21 <key>offsetX</key>
22 <real>0</real>
23 <key>offsetY</key>
24 <real>0</real>
25 </dict>
26 <key>defaultarmaturehat.png</key>
27 <dict>
28 <key>width</key>
29 <integer>45</integer>
30 <key>height</key>
31 <integer>45</integer>
32 <key>originalWidth</key>
33 <integer>45</integer>
34 <key>originalHeight</key>
35 <integer>45</integer>
36 <key>x</key>
37 <integer>22</integer>
38 <key>y</key>
39 <integer>0</integer>
40 <key>offsetX</key>
41 <real>0</real>
42 <key>offsetY</key>
43 <real>0</real>
44 </dict>
45 <key>defaultarmature7.png</key>
46 <dict>
47 <key>width</key>
48 <integer>14</integer>
49 <key>height</key>
50 <integer>11</integer>
51 <key>originalWidth</key>
52 <integer>14</integer>
53 <key>originalHeight</key>
54 <integer>11</integer>
55 <key>x</key>
56 <integer>69</integer>
57 <key>y</key>
58 <integer>0</integer>
59 <key>offsetX</key>
60 <real>0</real>
61 <key>offsetY</key>
62 <real>0</real>
63 </dict>
64 <key>defaultarmature2.png</key>
65 <dict>
66 <key>width</key>
67 <integer>18</integer>
68 <key>height</key>
69 <integer>25</integer>
70 <key>originalWidth</key>
71 <integer>18</integer>
72 <key>originalHeight</key>
73 <integer>25</integer>
74 <key>x</key>
75 <integer>85</integer>
76 <key>y</key>
77 <integer>0</integer>
78 <key>offsetX</key>
79 <real>0</real>
80 <key>offsetY</key>
81 <real>0</real>
82 </dict>
83 <key>defaultarmature6.png</key>
84 <dict>
85 <key>width</key>
86 <integer>47</integer>
87 <key>height</key>
88 <integer>40</integer>
89 <key>originalWidth</key>
90 <integer>47</integer>
91 <key>originalHeight</key>
92 <integer>40</integer>
93 <key>x</key>
94 <integer>105</integer>
95 <key>y</key>
96 <integer>0</integer>
97 <key>offsetX</key>
98 <real>0</real>
99 <key>offsetY</key>
100 <real>0</real>
101 </dict>
102 <key>defaultarmature4.png</key>
103 <dict>
104 <key>width</key>
105 <integer>14</integer>
106 <key>height</key>
107 <integer>11</integer>
108 <key>originalWidth</key>
109 <integer>14</integer>
110 <key>originalHeight</key>
111 <integer>11</integer>
112 <key>x</key>
113 <integer>154</integer>
114 <key>y</key>
115 <integer>0</integer>
116 <key>offsetX</key>
117 <real>0</real>
118 <key>offsetY</key>
119 <real>0</real>
120 </dict>
121 <key>defaultarmature5.png</key>
122 <dict>
123 <key>width</key>
124 <integer>19</integer>
125 <key>height</key>
126 <integer>23</integer>
127 <key>originalWidth</key>
128 <integer>19</integer>
129 <key>originalHeight</key>
130 <integer>23</integer>
131 <key>x</key>
132 <integer>170</integer>
133 <key>y</key>
134 <integer>0</integer>
135 <key>offsetX</key>
136 <real>0</real>
137 <key>offsetY</key>
138 <real>0</real>
139 </dict>
140 <key>defaultarmature3.png</key>
141 <dict>
142 <key>width</key>
143 <integer>24</integer>
144 <key>height</key>
145 <integer>47</integer>
146 <key>originalWidth</key>
147 <integer>24</integer>
148 <key>originalHeight</key>
149 <integer>47</integer>
150 <key>x</key>
151 <integer>191</integer>
152 <key>y</key>
153 <integer>0</integer>
154 <key>offsetX</key>
155 <real>0</real>
156 <key>offsetY</key>
157 <real>0</real>
158 </dict>
159 <key>defaultarmature8.png</key>
160 <dict>
161 <key>width</key>
162 <integer>13</integer>
163 <key>height</key>
164 <integer>18</integer>
165 <key>originalWidth</key>
166 <integer>13</integer>
167 <key>originalHeight</key>
168 <integer>18</integer>
169 <key>x</key>
170 <integer>217</integer>
171 <key>y</key>
172 <integer>0</integer>
173 <key>offsetX</key>
174 <real>0</real>
175 <key>offsetY</key>
176 <real>0</real>
177 </dict>
178 </dict>
179 <key>metadata</key>
180 <dict>
181 <key>format</key>
182 <integer>0</integer>
183 <key>textureFileName</key>
184 <string>DemoPlayer0.png</string>
185 <key>realTextureFileName</key>
186 <string>DemoPlayer0.png</string>
187 <key>size</key>
188 <string>{1024,1024}</string>
189 </dict>
190 <key>texture</key>
191 <dict>
192 <key>width</key>
193 <integer>1024</integer>
194 <key>height</key>
195 <integer>1024</integer>
196 </dict>
197 </dict>
198 </plist>
...\ No newline at end of file ...\ No newline at end of file
No preview for this file type
1 info face="΢ź" size=-72 bold=1 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=1,1 outline=0
2 common lineHeight=96 base=76 scaleW=256 scaleH=512 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4
3 page id=0 file="num_cake_green_0.png"
4 chars count=11
5 char id=43 x=93 y=336 width=78 height=70 xoffset=-1 yoffset=-1 xadvance=76 page=0 chnl=15
6 char id=48 x=101 y=84 width=98 height=83 xoffset=-1 yoffset=-1 xadvance=96 page=0 chnl=15
7 char id=49 x=202 y=0 width=52 height=83 xoffset=-1 yoffset=-1 xadvance=50 page=0 chnl=15
8 char id=50 x=0 y=336 width=92 height=83 xoffset=-1 yoffset=-1 xadvance=90 page=0 chnl=15
9 char id=51 x=0 y=168 width=96 height=83 xoffset=-1 yoffset=-1 xadvance=94 page=0 chnl=15
10 char id=52 x=97 y=168 width=96 height=83 xoffset=-1 yoffset=-1 xadvance=94 page=0 chnl=15
11 char id=53 x=0 y=252 width=96 height=83 xoffset=-1 yoffset=-1 xadvance=94 page=0 chnl=15
12 char id=54 x=97 y=252 width=96 height=83 xoffset=-1 yoffset=-1 xadvance=94 page=0 chnl=15
13 char id=55 x=0 y=0 width=100 height=83 xoffset=-1 yoffset=-1 xadvance=98 page=0 chnl=15
14 char id=56 x=101 y=0 width=100 height=83 xoffset=-1 yoffset=-1 xadvance=98 page=0 chnl=15
15 char id=57 x=0 y=84 width=100 height=83 xoffset=-1 yoffset=-1 xadvance=98 page=0 chnl=15
1 info face="΢ź" size=-72 bold=1 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=1,1 outline=0
2 common lineHeight=96 base=76 scaleW=128 scaleH=256 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4
3 page id=0 file="num_clock_0.png"
4 chars count=10
5 char id=48 x=0 y=0 width=43 height=54 xoffset=-1 yoffset=-1 xadvance=41 page=0 chnl=15
6 char id=49 x=0 y=165 width=27 height=54 xoffset=-1 yoffset=-1 xadvance=25 page=0 chnl=15
7 char id=50 x=88 y=0 width=39 height=54 xoffset=-1 yoffset=-1 xadvance=37 page=0 chnl=15
8 char id=51 x=42 y=55 width=40 height=54 xoffset=-1 yoffset=-1 xadvance=38 page=0 chnl=15
9 char id=52 x=44 y=0 width=43 height=54 xoffset=-1 yoffset=-1 xadvance=41 page=0 chnl=15
10 char id=53 x=82 y=110 width=39 height=54 xoffset=-1 yoffset=-1 xadvance=37 page=0 chnl=15
11 char id=54 x=83 y=55 width=40 height=54 xoffset=-1 yoffset=-1 xadvance=38 page=0 chnl=15
12 char id=55 x=0 y=55 width=41 height=54 xoffset=-1 yoffset=-1 xadvance=39 page=0 chnl=15
13 char id=56 x=0 y=110 width=40 height=54 xoffset=-1 yoffset=-1 xadvance=38 page=0 chnl=15
14 char id=57 x=41 y=110 width=40 height=54 xoffset=-1 yoffset=-1 xadvance=38 page=0 chnl=15
No preview for this file type
No preview for this file type
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3 <plist version="1.0">
4 <dict>
5 <key>frames</key>
6 <dict>
7 <key>bg_best_show.png</key>
8 <dict>
9 <key>frame</key>
10 <string>{{270,2},{202,82}}</string>
11 <key>offset</key>
12 <string>{0,0}</string>
13 <key>rotated</key>
14 <false/>
15 <key>sourceColorRect</key>
16 <string>{{0,1},{202,82}}</string>
17 <key>sourceSize</key>
18 <string>{202,84}</string>
19 </dict>
20 <key>bg_fanpai_num.png</key>
21 <dict>
22 <key>frame</key>
23 <string>{{270,86},{198,54}}</string>
24 <key>offset</key>
25 <string>{-1,1}</string>
26 <key>rotated</key>
27 <false/>
28 <key>sourceColorRect</key>
29 <string>{{0,2},{198,54}}</string>
30 <key>sourceSize</key>
31 <string>{200,60}</string>
32 </dict>
33 <key>btn_guess_introduce.png</key>
34 <dict>
35 <key>frame</key>
36 <string>{{260,399},{93,90}}</string>
37 <key>offset</key>
38 <string>{0,1}</string>
39 <key>rotated</key>
40 <true/>
41 <key>sourceColorRect</key>
42 <string>{{2,1},{93,90}}</string>
43 <key>sourceSize</key>
44 <string>{97,94}</string>
45 </dict>
46 <key>btn_guess_next.png</key>
47 <dict>
48 <key>frame</key>
49 <string>{{2,2},{266,91}}</string>
50 <key>offset</key>
51 <string>{0,0}</string>
52 <key>rotated</key>
53 <false/>
54 <key>sourceColorRect</key>
55 <string>{{0,0},{266,91}}</string>
56 <key>sourceSize</key>
57 <string>{266,91}</string>
58 </dict>
59 <key>candy_1.png</key>
60 <dict>
61 <key>frame</key>
62 <string>{{96,294},{107,106}}</string>
63 <key>offset</key>
64 <string>{0,0}</string>
65 <key>rotated</key>
66 <true/>
67 <key>sourceColorRect</key>
68 <string>{{0,0},{107,106}}</string>
69 <key>sourceSize</key>
70 <string>{107,106}</string>
71 </dict>
72 <key>candy_1001.png</key>
73 <dict>
74 <key>frame</key>
75 <string>{{265,142},{42,60}}</string>
76 <key>offset</key>
77 <string>{0,0}</string>
78 <key>rotated</key>
79 <false/>
80 <key>sourceColorRect</key>
81 <string>{{0,0},{42,60}}</string>
82 <key>sourceSize</key>
83 <string>{42,60}</string>
84 </dict>
85 <key>candy_1002.png</key>
86 <dict>
87 <key>frame</key>
88 <string>{{2,427},{72,78}}</string>
89 <key>offset</key>
90 <string>{0,0}</string>
91 <key>rotated</key>
92 <false/>
93 <key>sourceColorRect</key>
94 <string>{{0,0},{72,78}}</string>
95 <key>sourceSize</key>
96 <string>{72,78}</string>
97 </dict>
98 <key>candy_1003.png</key>
99 <dict>
100 <key>frame</key>
101 <string>{{76,427},{88,75}}</string>
102 <key>offset</key>
103 <string>{0,0}</string>
104 <key>rotated</key>
105 <false/>
106 <key>sourceColorRect</key>
107 <string>{{0,0},{88,75}}</string>
108 <key>sourceSize</key>
109 <string>{88,75}</string>
110 </dict>
111 <key>candy_1004.png</key>
112 <dict>
113 <key>frame</key>
114 <string>{{136,224},{93,67}}</string>
115 <key>offset</key>
116 <string>{0,0}</string>
117 <key>rotated</key>
118 <false/>
119 <key>sourceColorRect</key>
120 <string>{{0,0},{93,67}}</string>
121 <key>sourceSize</key>
122 <string>{93,67}</string>
123 </dict>
124 <key>candy_1005.png</key>
125 <dict>
126 <key>frame</key>
127 <string>{{231,224},{61,44}}</string>
128 <key>offset</key>
129 <string>{0,0}</string>
130 <key>rotated</key>
131 <true/>
132 <key>sourceColorRect</key>
133 <string>{{0,0},{61,44}}</string>
134 <key>sourceSize</key>
135 <string>{61,44}</string>
136 </dict>
137 <key>candy_2.png</key>
138 <dict>
139 <key>frame</key>
140 <string>{{166,403},{104,92}}</string>
141 <key>offset</key>
142 <string>{0,0}</string>
143 <key>rotated</key>
144 <true/>
145 <key>sourceColorRect</key>
146 <string>{{0,0},{104,92}}</string>
147 <key>sourceSize</key>
148 <string>{104,92}</string>
149 </dict>
150 <key>candy_2001.png</key>
151 <dict>
152 <key>frame</key>
153 <string>{{2,294},{131,92}}</string>
154 <key>offset</key>
155 <string>{0,0}</string>
156 <key>rotated</key>
157 <true/>
158 <key>sourceColorRect</key>
159 <string>{{0,0},{131,92}}</string>
160 <key>sourceSize</key>
161 <string>{131,92}</string>
162 </dict>
163 <key>candy_2002.png</key>
164 <dict>
165 <key>frame</key>
166 <string>{{165,95},{98,127}}</string>
167 <key>offset</key>
168 <string>{0,0}</string>
169 <key>rotated</key>
170 <false/>
171 <key>sourceColorRect</key>
172 <string>{{0,0},{98,127}}</string>
173 <key>sourceSize</key>
174 <string>{98,127}</string>
175 </dict>
176 <key>candy_2003.png</key>
177 <dict>
178 <key>frame</key>
179 <string>{{2,198},{94,132}}</string>
180 <key>offset</key>
181 <string>{0,0}</string>
182 <key>rotated</key>
183 <true/>
184 <key>sourceColorRect</key>
185 <string>{{0,0},{94,132}}</string>
186 <key>sourceSize</key>
187 <string>{94,132}</string>
188 </dict>
189 <key>candy_3.png</key>
190 <dict>
191 <key>frame</key>
192 <string>{{204,293},{88,104}}</string>
193 <key>offset</key>
194 <string>{0,0}</string>
195 <key>rotated</key>
196 <false/>
197 <key>sourceColorRect</key>
198 <string>{{0,0},{88,104}}</string>
199 <key>sourceSize</key>
200 <string>{88,104}</string>
201 </dict>
202 <key>candy_3001.png</key>
203 <dict>
204 <key>frame</key>
205 <string>{{2,95},{161,101}}</string>
206 <key>offset</key>
207 <string>{0,0}</string>
208 <key>rotated</key>
209 <false/>
210 <key>sourceColorRect</key>
211 <string>{{0,0},{161,101}}</string>
212 <key>sourceSize</key>
213 <string>{161,101}</string>
214 </dict>
215 </dict>
216 <key>metadata</key>
217 <dict>
218 <key>format</key>
219 <integer>2</integer>
220 <key>realTextureFileName</key>
221 <string>candy_textures.png</string>
222 <key>size</key>
223 <string>{512,512}</string>
224 <key>smartupdate</key>
225 <string>$TexturePacker:SmartUpdate:fcc5e2e8bfcc5afc79643ea454503b13:1/1$</string>
226 <key>textureFileName</key>
227 <string>candy_textures.png</string>
228 </dict>
229 </dict>
230 </plist>
1 <?xml version="1.0"?>
2 <Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3 <propertyGroup>
4 <StartProgram>D:\xhx\client\runtime\win32\GuandanAndroid.exe</StartProgram>
5 <StartArguments>-workdir D:\xhx\client\rubbish\client</StartArguments>
6 <StartWorkingDirectory>D:\xhx\client\runtime\win32</StartWorkingDirectory>
7 </propertyGroup>
8 </Project>
...\ No newline at end of file ...\ No newline at end of file
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
36 <Folder Include="src\app\tools\pl\" /> 36 <Folder Include="src\app\tools\pl\" />
37 <Folder Include="src\app\views\" /> 37 <Folder Include="src\app\views\" />
38 <Folder Include="src\app\views\effect\" /> 38 <Folder Include="src\app\views\effect\" />
39 <Folder Include="src\app\views\candy\" /> 39 <Folder Include="src\app\views\rubbish\" />
40 <Folder Include="src\app\views\scene\" /> 40 <Folder Include="src\app\views\scene\" />
41 <Folder Include="src\app\views\view\" /> 41 <Folder Include="src\app\views\view\" />
42 <Folder Include="src\cocos\" /> 42 <Folder Include="src\cocos\" />
...@@ -91,14 +91,14 @@ ...@@ -91,14 +91,14 @@
91 <Compile Include="src\app\tools\pl\compat.lua" /> 91 <Compile Include="src\app\tools\pl\compat.lua" />
92 <Compile Include="src\app\tools\pl\utils.lua" /> 92 <Compile Include="src\app\tools\pl\utils.lua" />
93 <Compile Include="src\app\tools\pl\xml.lua" /> 93 <Compile Include="src\app\tools\pl\xml.lua" />
94 <Compile Include="src\app\views\candy\Candy.lua" /> 94 <Compile Include="src\app\views\rubbish\Rubbish.lua" />
95 <Compile Include="src\app\views\candy\GameFailView.lua" /> 95 <Compile Include="src\app\views\rubbish\GameFailView.lua" />
96 <Compile Include="src\app\views\candy\GameNextView.lua" /> 96 <Compile Include="src\app\views\rubbish\GameNextView.lua" />
97 <Compile Include="src\app\views\candy\GamePayConfirmView.lua" /> 97 <Compile Include="src\app\views\rubbish\GamePayConfirmView.lua" />
98 <Compile Include="src\app\views\candy\GamePayView.lua" /> 98 <Compile Include="src\app\views\rubbish\GamePayView.lua" />
99 <Compile Include="src\app\views\candy\game_data.lua" /> 99 <Compile Include="src\app\views\rubbish\game_data.lua" />
100 <Compile Include="src\app\views\candy\GameOverView.lua" /> 100 <Compile Include="src\app\views\rubbish\GameOverView.lua" />
101 <Compile Include="src\app\views\candy\GameStartView.lua" /> 101 <Compile Include="src\app\views\rubbish\GameStartView.lua" />
102 <Compile Include="src\app\views\effect\EffectBoom.lua" /> 102 <Compile Include="src\app\views\effect\EffectBoom.lua" />
103 <Compile Include="src\app\views\effect\EffectFntPop.lua" /> 103 <Compile Include="src\app\views\effect\EffectFntPop.lua" />
104 <Compile Include="src\app\views\effect\EffectFruitLight.lua" /> 104 <Compile Include="src\app\views\effect\EffectFruitLight.lua" />
...@@ -110,9 +110,9 @@ ...@@ -110,9 +110,9 @@
110 <Compile Include="src\app\views\effect\EffectStright.lua" /> 110 <Compile Include="src\app\views\effect\EffectStright.lua" />
111 <Compile Include="src\app\views\effect\EffectVoiceChat.lua" /> 111 <Compile Include="src\app\views\effect\EffectVoiceChat.lua" />
112 <Compile Include="src\app\views\scene\BaseScene.lua" /> 112 <Compile Include="src\app\views\scene\BaseScene.lua" />
113 <Compile Include="src\app\views\candy\LoadingScene.lua" />
114 <Compile Include="src\app\views\candy\GameScene.lua" />
115 <Compile Include="src\app\views\scene\BaseSceneNew.lua" /> 113 <Compile Include="src\app\views\scene\BaseSceneNew.lua" />
114 <Compile Include="src\app\views\rubbish\LoadingScene.lua" />
115 <Compile Include="src\app\views\rubbish\GameScene.lua" />
116 <Compile Include="src\app\views\view\AlertView.lua" /> 116 <Compile Include="src\app\views\view\AlertView.lua" />
117 <Compile Include="src\app\views\view\BaseView.lua" /> 117 <Compile Include="src\app\views\view\BaseView.lua" />
118 <Compile Include="src\app\views\view\BaseViewNew.lua" /> 118 <Compile Include="src\app\views\view\BaseViewNew.lua" />
......
1 local BaseData = class("BaseData")
2
3 local password = "zhjianctkj0571";
4
5 function BaseData:ctor( fileName )
6 self.fileName = fileName
7 self.data = {}
8 end
9
10 function BaseData:saveToFile( )
11 local str = json.encode(self.data)
12 local targetPlatform = cc.Application:getInstance():getTargetPlatform()
13 if targetPlatform ~= cc.PLATFORM_OS_WINDOWS then
14 -- str = MCCrypto:encryptXXTEA(str, string.len(str), password, string.len(password));
15 end
16 local fullFilename = cc.FileUtils:getInstance():getWritablePath()..self.fileName
17 local file = io.open(fullFilename, "w")
18 file:write(str)
19 file:close()
20 end
21
22 function BaseData:readFromFile( )
23 local result = false
24 local fullFilename = cc.FileUtils:getInstance():getWritablePath()..self.fileName
25 local file = io.open(fullFilename, "r")
26
27 if file then
28 local str= file:read("*all")
29 -- print(str)
30 file:close()
31 if pcall(function()
32 local targetPlatform = cc.Application:getInstance():getTargetPlatform()
33 if targetPlatform ~= cc.PLATFORM_OS_WINDOWS then
34 -- str = MCCrypto:decryptXXTEA(str, string.len(str), password, string.len(password))
35 end
36 self.data = json.decode(str)
37 result = true
38 end) then
39 --todo
40 else
41 self.data = {}
42 print("invalid json data: "..self.fileName)
43 end
44 else
45
46 self.data = {}
47 end
48
49 return result
50 end
51
52 function BaseData:resetData( )
53 self.data = {}
54 self:saveToFile()
55 end
56
57 return BaseData
...\ No newline at end of file ...\ No newline at end of file
1
2 local MyApp = class("MyApp", cc.load("mvc").AppBase) 1 local MyApp = class("MyApp", cc.load("mvc").AppBase)
3 2
4 function MyApp:onCreate() 3 function MyApp:onCreate()
5 math.randomseed(os.time()) 4 math.randomseed(os.time());
5 end
6
7 --function MyApp:enterScene(sceneName, transition, time, more)
8 -- return display.runScene(display.newScene(sceneName),transition,time,more)
9 --end
10
11 function MyApp:enterScene(sceneName, args, transitionType, time, more)
12 local scenePackageName = "src.app.views.scene."..sceneName;
13 print("볡"..scenePackageName);
14 local sceneClass = require(scenePackageName)
15 -- local scene = sceneClass.new(unpack(checktable(args)))
16 local scene = sceneClass.new(args)
17 display.runScene(scene, transitionType, time, more)
18 end
19
20 function MyApp:enterMiniGameScene(sceneName, args, transitionType, time, more)
21 local scenePackageName = "src.app.views."..sceneName;
22 print("볡"..scenePackageName);
23 local sceneClass = require(scenePackageName)
24 -- local scene = sceneClass.new(unpack(checktable(args)))
25 local scene = sceneClass.new(args)
26 display.runScene(scene, transitionType, time, more)
6 end 27 end
7 28
8 return MyApp 29 return MyApp
......
1 cc.exports.GameConfig={}; local xml = require("core.utils.pl.xml"); GameConfig.relief_cnt = 2;GameConfig.relief_base = 2000; --低保底限 return GameConfig;
...\ No newline at end of file ...\ No newline at end of file
1 cc.exports.strings = {}
2 strings.msg_100 = "版本已经升级,请更新以便更好的体验游戏!";
3 strings.msg_101 = "无法获取服务器地址,请联系商家!";
4 strings.msg_1001 = "服务器出现异常,请重新登录!";
5 strings.msg_1002 = "网络已断开,请检查网络是否正常!";
6 strings.msg_1003 = "点券不足,去充值吧?";
7 strings.msg_1004 = "登录失败,请检查网络连接是否正常!";
8 strings.msg_1005 = "您的账号已在其他地方登录!";
9 strings.msg_1006 = "你慢了一步,此昵称已被使用!";
10 strings.msg_1007 = "昵称修改成功!";
11 strings.msg_1008 = "请随机选择一个昵称!";
12 strings.msg_1009 = "头像修改成功!";
13 strings.msg_1010 = "未知错误";
14 strings.msg_1011 = "已经是当前头像!";
15 strings.msg_1012 = "每局扣除1张房卡";
16 strings.msg_1013 = "房主每局扣除4张房卡";
17 strings.msg_1014 = "每局开始消耗%s金币";
18 strings.msg_1015 = "我的房卡数量:%s张";
19 strings.msg_1016 = "今日抽奖已完成!";
20 strings.msg_1017 = "需要完成%s局才能进行抽奖";
21 strings.msg_1018 = "时间没到,无法领取!";
22 strings.msg_1019 = "每局扣除4张房卡";
23 strings.msg_1020 = "你的金币太多啦,高倍场才适合您!前往赚个盆满钵满吧!";
24 strings.msg_1021 = "长时间未操作,你已经离开游戏";
25 strings.msg_1022 = "你已经离开游戏";
26 strings.msg_1023 = "目前金币不足,给您发放今日补助\n金币%s,祝您游戏愉快!";
27 strings.msg_1024 = "返回到游戏大厅?";
28 strings.msg_1025 = "今日获得%s已达上限";
29 strings.msg_1026 = "勋章不足";
30
31 strings.msg_2001 = "牌型不对哦!";
32 strings.msg_2002 = "是否确定要退出游戏房间?";
33 strings.msg_2003 = "金币不足";
34 strings.msg_2004 = "房主离开,房间解散!";
35 strings.msg_2005 = "游戏正在进行中,确定要退出吗?";
36 strings.msg_2006 = "无法进入该房间";
37 strings.msg_2007 = "房间已满";
38 strings.msg_2008 = "道具不足";
39 strings.msg_2009 = "房卡不足,是否去购买?";
40 strings.msg_2010 = "补签卡不足,是否去购买?";
41 strings.msg_2011 = "该道具不存在";
42 strings.msg_2012 = "无法使用该道具";
43 strings.msg_2013 = "金币不足,去快速获得吗?";
44 strings.msg_2014 = "抗贡";
45 strings.msg_2015 = "不符合还贡规则!";
46 strings.msg_2016 = "不符合进贡规则!";
47 strings.msg_2017 = "购买失败!";
48 strings.msg_2018 = "没有牌大过上家";
49 strings.msg_2019 = "牌不够大哦!";
50 strings.msg_2020 = "出更大的“%s”管他!";
51 strings.msg_2021 = "不会吧,“天王炸”你也想管!";
52 strings.msg_2022 = "只能出“三带二”或“三张”哦!";
53 strings.msg_2023 = "只能出5张连续的“顺子”!";
54 strings.msg_2024 = "只能出3连对的“木板”!";
55 strings.msg_2025 = "只能出2连三张的“钢板”!";
56 strings.msg_2026 = "没有同花顺!";
57 strings.msg_2027 = "先选中要单独放置的牌!";
58 strings.msg_2028 = "离开房间会切换至托管模式,确定要离开吗?";
59 strings.msg_2029 = "正在牌局中,无法退出!";
60 strings.msg_2030 = "暂无战况信息";
61 strings.msg_2031 = "请先选择水果押注!";
62 strings.msg_2032 = "请选择要出的牌!";
63 return strings;
...\ No newline at end of file ...\ No newline at end of file
1 EnumErrorCode = {}
2 EnumErrorCode.EC_SUCCESS = 0; --成功
3 EnumErrorCode.EC_ERR_CODE = 1; --错误
4 EnumErrorCode.EC_VALUE_INVALID = 2; --无效数值
5 EnumErrorCode.EC_LOGIN_T = 3; --被登陆上来的用户T掉
6 EnumErrorCode.EC_INEXISTENT_ITEM = 4; --不存在,道具
7 EnumErrorCode.EC_INEXISTENT_USER = 5; --不存在,用户
8 EnumErrorCode.EC_EXISTENT_ROLE = 6; --存在,角色
9 EnumErrorCode.EC_INEXISTENT_ACCOUNT = 7; --不存在,帐号
10 EnumErrorCode.EC_NO_APPROVED = 8; --尚未通过身份校验
11 EnumErrorCode.EC_EVENT_LIMIT = 9; --事件上限
12 EnumErrorCode.EC_USER_LEVEL = 10; --用户等级不足
13 EnumErrorCode.EC_USER_BTL = 11; --用户在战斗状态
14 EnumErrorCode.EC_PASSWORD = 14; --密码错误
15 EnumErrorCode.EC_CHAT_LEN_MAX = 15; --聊天长度上限
16 EnumErrorCode.EC_EXCEL_ERROR = 17; --配置表错误
17 EnumErrorCode.EC_BUY_TIMES_UP_TO_LIMIT = 18; --购买次数达到上限
18 EnumErrorCode.EC_USER_IN_ROOM = 19; --用户在房间
19 EnumErrorCode.EC_USER_BASE_MONEY = 20; --用户押金不足
20 EnumErrorCode.EC_USER_OUT_ROOM = 21; --用户在房间外
21 EnumErrorCode.EC_USER_IN_RUM_ROOM = 22; --用户在运行的房间
22 EnumErrorCode.EC_USER_IN_LOBBY = 23; --用户在大厅中
23 EnumErrorCode.EC_USER_OUT_LOBBY = 24; --用户不在大厅中
24 EnumErrorCode.EC_USER_NICK_EXIST = 25; --用户昵称已存在
25 EnumErrorCode.EC_INEXISTENT_ROOM = 26; --不存在,房间
26 EnumErrorCode.EC_FULL_ROOM = 27; --满,房间
27 EnumErrorCode.EC_MAIL_INEXISTENT = 28; --邮件不存在
28 EnumErrorCode.EC_MAIL_ATTACHMENT_INEXISTENT = 29; --邮件无附件
...\ No newline at end of file ...\ No newline at end of file
1 EnumEvent={};EnumEvent.SOCKET_DISCONNECT = "socket_disconnect";EnumEvent.SOCKET_RECONNECT = "socket_reconnect"; EnumEvent.LOGIN_SUCCESS = "login_success";EnumEvent.LOGIN_FAILD = "login_faild"; EnumEvent.USER_INFO = "user_info"; EnumEvent.ROOM_ENTER_MULTI = "room_enter_multi";EnumEvent.ROOM_ENTER_FAILD = "room_enter_faild";EnumEvent.ROOM_ENTER_FAILD_BUY_CARD_SUCCESS = "room_enter_faild_buy_card_success"; EnumEvent.ROOM_USERS = "room_users";EnumEvent.ROOM_USERS_SCORE = "room_users_score";EnumEvent.ROOM_MY_POKERS = "room_my_pokers";EnumEvent.ROOM_GONG_FLAG = "room_gong_flag";EnumEvent.ROOM_JIN_HUAN_GONG = "room_jin_huan_gong";EnumEvent.GAME_WHO_SHOT = "game_who_shot";EnumEvent.GAME_SHOT_POKERS = "game_shot_pokers";EnumEvent.GAME_SHOT_ERROR = "game_shot_error";EnumEvent.GAME_PASS = "game_pass";EnumEvent.GAME_ALL_PASS = "game_all_pass";EnumEvent.GAME_POKER_FINISH = "game_poker_finish";EnumEvent.GAME_RET = "game_ret";EnumEvent.GAME_OVER = "game_over";EnumEvent.GAME_DEBUG_POKER = "game_debug_poker"; EnumEvent.SINGLE_POKER_GONG = "single_poker_gong";EnumEvent.SINGLE_POKER_SHOT = "single_poker_shot"; EnumEvent.POKER_NUM = "poker_num"; --剩余牌数量事件 EnumEvent.UPDATE_ITEMS = "update_items"; --更新道具 EnumEvent.UPDATE_COUPONS = "update_coupons"; --更新点券 EnumEvent.UPDATE_COIN = "update_coin"; --更新金币 EnumEvent.UPDATE_CHARM = "update_charm"; --更新魅力值 EnumEvent.UPDATE_TASK = "update_task"; --更新任务 EnumEvent.UPDATE_MAIL = "update_mail"; --更新邮件 EnumEvent.UPDATE_RANK_REWARD = "update_rank_reward"; --更新排行榜奖励 EnumEvent.UPDATE_ACTIVITY = "update_activity"; --更新活动 EnumEvent.UPDATE_WIN = "update_win"; --更新胜利次数 EnumEvent.UPDATE_LOST = "update_lost"; --更新失败次数 EnumEvent.UPDATE_SCORE = "update_score"; --更新分数 EnumEvent.UPDATE_VIP = "update_vip"; --更新VIP EnumEvent.UPDATE_FIRST_PAY = "update_first_pay"; --更新首充礼包 EnumEvent.UPDATE_FIRST_CYCLE_PAY = "update_first_cycle_pay"; --更新周期首充礼包 EnumEvent.UPDATE_FREE_ITEM = "update_free_item"; --更新免费项信息 EnumEvent.USE_ITEM = "use_item"; --使用道具 EnumEvent.NICK_CHANGE_SUCCESS = "nick_change_success"; --昵称修改成功 EnumEvent.HEAD_CHANGE_SUCCESS = "head_change_success"; --头像修改成功 EnumEvent.HEAD_FRAME_CHANGE_SUCCESS = "head_frame_change_success"; --头像框修改成功 EnumEvent.MJ_ZHUANG = "mj_zhuang"; --麻将庄家 EnumEvent.MJ_DING = "mj_ding"; --麻将定牌 EnumEvent.MJ_DA = "mj_da"; --麻将打牌 EnumEvent.MJ_FA_NOTIFY = "mj_fa_notify"; --麻将发牌通知 EnumEvent.MJ_HGPG = "mj_hgpg"; --麻将胡杠碰过 EnumEvent.MJ_PENG = "mj_peng"; --麻将碰 EnumEvent.MJ_GANG = "mj_gang"; --麻将杠 EnumEvent.MJ_HU = "mj_hu"; --麻将杠 EnumEvent.MJ_GUO = "mj_guo"; --麻将过 EnumEvent.MJ_YI_PAO_DUO_XIANG = "mj_yi_pao_duo_xiang"; --麻将一炮多响 EnumEvent.MJ_NODE_UPDATE = "mj_node_update"; --麻将更新 EnumEvent.MJ_ROOM_ADD_MONEY = "mj_room_add_money"; --麻将加钱 EnumEvent.MJ_ROOM_REDUCE_MONEY = "mj_room_reduce_money"; --麻将减钱 EnumEvent.MJ_UPDATE_SELECTED_STATE = "mj_update_selected_state"; --麻将选中状态更新 EnumEvent.MJ_RECOMMEND_HUAN_KEY = "mj_recommend_huan_key"; --麻将推荐换牌消息 EnumEvent.MJ_HUAN_KEY = "mj_huan_key"; --麻将换牌消息 EnumEvent.NN_TIME_START = "nn_time_start"; --牛牛开始倒计时时间 EnumEvent.ACT_SHOW_FIGHT_LOTTERY = "act_show_fight_lottery"; EnumEvent.ACT_GET_LOTTERY = "act_get_lottery"; EnumEvent.DDZ_NOTIFY_LANDLORD = "ddz_notify_landlord"; EnumEvent.DDZ_ACTION_RES = "ddz_action_res";
...\ No newline at end of file ...\ No newline at end of file
1 EnumGame = {}
2 EnumGame.MAIN = 0; --大厅
3 EnumGame.CAKE = 1; --欢乐叠蛋糕
4 EnumGame.FANPAI = 2; --记忆翻拍
5 EnumGame.GUESS = 3; --猜猜我是谁
6 EnumGame.GUESS_COLOR = 4; --它的颜色
7 EnumGame.Runbbish = 5; --接糖果
8 EnumGame.SHUYISHU = 6; --数一数
9 EnumGame.RABBIT = 7; --奔跑吧小兔子
10 EnumGame.HAIDAO = 8; --旋转海盗
11 EnumGame.FEIYANZOUBI = 9; --飞檐走壁
12 EnumGame.BIRD = 10; --水管小鸟
...\ No newline at end of file ...\ No newline at end of file
1 EnumNodeType = {}
2 EnumNodeType.POKER = "poker";
3 EnumNodeType.DDZ_POKER = "ddz_poker";
4 EnumNodeType.MJ = "mj";
5 EnumNodeType.LAYER = "layer";
6 EnumNodeType.MAIL = "mail";
...\ No newline at end of file ...\ No newline at end of file
1 import(".EnumEvent");
2 import(".EnumNodeType");
3 import(".EnumErrorCode");
4 import(".EnumGame");
...\ No newline at end of file ...\ No newline at end of file
1 cc.exports.EventListener = {}
2
3 --事件侦听 node==nil时表示全局侦听
4 function EventListener.addEventListener(node,customEventName,fun)
5 local listener;
6 if node ~= nil then
7 local eventDispatcher = node:getEventDispatcher();
8 listener = cc.EventListenerCustom:create(customEventName, fun);
9 eventDispatcher:addEventListenerWithSceneGraphPriority(listener,node);
10 else
11 local eventDispatcher = cc.Director:getInstance():getEventDispatcher();
12 listener = cc.EventListenerCustom:create(customEventName,fun);
13 eventDispatcher:addEventListenerWithFixedPriority(listener,1);
14 end
15 return listener;
16 end
17
18 function EventListener.removeCustomEventListeners(node,customEventName)
19 local eventDispatcher = nil;
20 if node ~= nil then
21 eventDispatcher = node:getEventDispatcher();
22 else
23 eventDispatcher = cc.Director:getInstance():getEventDispatcher();
24 end
25 eventDispatcher:removeCustomEventListeners(customEventName);
26 end
27
28 function EventListener.removeEventListener(node,listener)
29 local eventDispatcher = nil;
30 if node ~= nil then
31 eventDispatcher = node:getEventDispatcher();
32 else
33 eventDispatcher = cc.Director:getInstance():getEventDispatcher();
34 end
35 eventDispatcher:removeEventListener(listener)
36 end
37
38 function EventListener.removeAllEventListeners(node)
39 local eventDispatcher = node:getEventDispatcher();
40 eventDispatcher:removeAllEventListeners();
41 end
42
43 function EventListener.dispatchEvent(eventType,data)
44 local eventDispatcher = cc.Director:getInstance():getEventDispatcher();
45 local event = cc.EventCustom:new(eventType)
46 if data ~= nil then
47 event.data = data;
48 end
49 eventDispatcher:dispatchEvent(event);
50 end
51
52 return EventListener
...\ No newline at end of file ...\ No newline at end of file
1 cc.exports.ConfigInfo = {}
2
3 local configMap = {};
4
5 local function str_split(str,split_char)
6 str = tostring(str);
7 local sub_str_tab = {};
8 while (true) do
9 local pos = nil
10 for i = 1, #str do
11 if string.sub(str, i, i) == split_char then
12 pos = i
13 break
14 end
15 end
16 if (not pos) then
17 sub_str_tab[#sub_str_tab + 1] = str;
18 break;
19 end
20 local sub_str = string.sub(str, 1, pos - 1);
21 sub_str_tab[#sub_str_tab + 1] = sub_str;
22 str = string.sub(str, pos + 1, #str);
23 end
24
25 return sub_str_tab;
26 end
27
28 --配置表信息
29 local function init()
30 local itemStr = cc.FileUtils:getInstance():getStringFromFile("config.ini");
31 local function readLineFun(lineStr)
32 local contents = str_split(lineStr,'=');
33 if #contents > 1 then
34 configMap[contents[1]] = contents[2];
35 end
36 end
37
38 local index = 1;
39 local function readLine(str)
40 local a,b = string.find(str,"\r\n");
41 if a then
42 local lineStr = string.sub(str,1,a-1);
43 readLineFun(lineStr);
44
45 index = index + 1;
46 str = string.sub(str,b+1);
47 readLine(str);
48 else
49 readLineFun(str);
50 end
51 end
52 readLine(itemStr);
53 end
54 init();
55
56 --通过ID获取信息
57 function ConfigInfo.getConfigInfo(id)
58 return configMap[tostring(id)];
59 end
60
61 --读取txt配置
62 function ConfigInfo.readTxtLines(linesStr)
63 local lineMap = {};
64 local function readLineFun(lineStr)
65 local contents = str_split(lineStr,'=');
66 lineMap[contents[1]] = contents[2];
67 end
68
69 local index = 1;
70 local function readLine(str)
71 local a,b = string.find(str,"\r\n");
72 if a then
73 local lineStr = string.sub(str,1,a-1);
74 readLineFun(lineStr);
75
76 index = index + 1;
77 str = string.sub(str,b+1);
78 readLine(str);
79 else
80 readLineFun(str);
81 end
82 end
83 readLine(linesStr);
84 return lineMap;
85 end
86
87 return ConfigInfo
...\ No newline at end of file ...\ No newline at end of file
1 cc.exports.Alert = {}
2
3 function Alert.showOne(msg,okFun,cancelFun)
4 local receiver = require("app.views.view.AlertOneView"):show(msg,okFun,cancelFun);
5
6 local scene = cc.Director:getInstance():getRunningScene();
7 scene.keypadManager:addKeypadReceiver(receiver);
8 end
9
10 function Alert.showTwo(msg,okFun,cancelFun,selectedIndex)
11 local receiver = require("app.views.view.AlertTwoView"):show(msg,okFun,cancelFun,selectedIndex);
12
13 local scene = cc.Director:getInstance():getRunningScene();
14 scene.keypadManager:addKeypadReceiver(receiver);
15 end
16
17 function Alert.showNoMoney(shopID,okFun,cancelFun)
18 local scene = cc.Director:getInstance():getRunningScene();
19 local receiver;
20
21 local firstPayInfo = ActivityModel.getCurrentFirstPayInfo();
22 local shopInfo = ShopInfo.getShopInfo(shopID);
23 local costId = shopInfo.costList[1].id;
24 local costNum = shopInfo.costList[1].num;
25 local myNum = UserModel.getItemNum(costId);
26 print(costId,"my num:",myNum,"cost num:",costNum)
27 if UserModel.relief_cnt > 0 and UserModel.getCoin() < GameConfig.relief_base then
28 receiver = require("app.views.view.ReliefView"):show();
29 receiver.okFun = okFun;
30 elseif firstPayInfo and tonumber(firstPayInfo.costList[1].num) == 1.0 and myNum < costNum then
31 receiver = require("app.views.view.ActivityView"):show("ActivityFirstPayView");
32 receiver.okFun = okFun;
33 receiver.cancelFun = cancelFun;
34 EffectManager.showFntPop(strings.msg_2003);
35 else
36 receiver = require("app.views.view.AlertNoMoneyView"):show(shopID,okFun,cancelFun);
37 end
38 scene.keypadManager:addKeypadReceiver(receiver);
39 end
40
41 return Alert
...\ No newline at end of file ...\ No newline at end of file
1 cc.exports.AppManager = {}
2
3 function AppManager.show(appname,params)
4 local receiver = require("app.views.view."..appname):show(params);
5
6 local scene = cc.Director:getInstance():getRunningScene();
7 scene.keypadManager:addKeypadReceiver(receiver);
8 end
9
10 return Alert
...\ No newline at end of file ...\ No newline at end of file
1 cc.exports.EffectManager=class("EffectManager")
2
3 local EffectScaleIn = require("app.views.effect.EffectScaleIn");
4 local EffectVoiceChat = require("app.views.effect.EffectVoiceChat");
5 local EffectBoom = require("app.views.effect.EffectBoom");
6 local EffectStright = require("app.views.effect.EffectStright");
7 local EffectPlayLevel = require("app.views.effect.EffectPlayLevel");
8 local EffectFntPop = require("app.views.effect.EffectFntPop");
9
10 --显示停留然后缩小特效
11 function EffectManager.showScaleInEffect(effectName,position)
12 local scene = cc.Director:getInstance():getRunningScene();
13
14 local eff = EffectScaleIn:create("res/effects/"..effectName..".png");
15 eff:setPosition(position);
16 scene:addChild(eff);
17 end
18
19 function EffectManager.showFntPop(msg)
20 local scene = cc.Director:getInstance():getRunningScene();
21
22 local eff = EffectFntPop:create(msg);
23 eff:setPosition(cc.p(display.width/2,display.height*2/3));
24 scene:addChild(eff,200);
25 end
26
27 --显示语音聊天效果
28 function EffectManager.showVoiceChatEffect(msg,position)
29 local scene = cc.Director:getInstance():getRunningScene();
30
31 local eff = EffectVoiceChat:create(msg);
32 eff:setPosition(position);
33 scene:addChild(eff);
34 end
35
36 --显示放大停留然后缩小 特效
37 function EffectManager.showScaleOutEffect(effectName,position)
38 local scene = cc.Director:getInstance():getRunningScene();
39
40 local eff = EffectBoom:create("res/effects/"..effectName..".png");
41 eff:setPosition(position);
42 scene:addChild(eff);
43 end
44
45 --显示顺子特效 从左往右飘过特效
46 function EffectManager.showStrightEffect(effectName,position)
47 position = position or cc.p(0,0);
48
49 local scene = cc.Director:getInstance():getRunningScene();
50
51 if scene:getChildByName(effectName) then
52 scene:removeChildByName(effectName);
53 end
54 local eff = EffectStright:create("res/effects/"..effectName..".png");
55 eff:setName(effectName);
56 eff:setPosition(position);
57 scene:addChild(eff);
58 end
59
60 --显示本局大几特效
61 function EffectManager.showPlayLevelEffect(poker_point,position)
62 local scene = cc.Director:getInstance():getRunningScene();
63
64 local eff = EffectPlayLevel:create(poker_point);
65 eff:setPosition(position);
66 scene:addChild(eff);
67 end
68
69 --显示闪光效果
70 function EffectManager.showFlashEffect(node)
71 if not node.flashAction then
72 local fadeIn = cc.FadeIn:create(0.8);
73 local fadeOut = cc.FadeOut:create(0.8);
74 node.flashAction = cc.RepeatForever:create(cc.Sequence:create(fadeIn,fadeOut));
75 node:runAction(node.flashAction);
76 end
77 end
78
79 --移除闪光效果
80 function EffectManager.removeFlashEffect(node)
81 if node.flashAction then
82 node:stopAction(node.flashAction);
83 node.flashAction = nil;
84 end
85 end
86
87 --回弹效果
88 function EffectManager.bounceNode(node)
89 if not node.scale then
90 node.scale = node:getScale();
91 end
92 -- node:setScale(node.scale+0.15);
93 local scaleTo = cc.ScaleTo:create(0.2,node.scale+0.15,node.scale+0.15);
94 local scaleTo1 = cc.EaseBounceOut:create(cc.ScaleTo:create(1,node.scale,node.scale));
95 node:runAction(cc.Sequence:create(scaleTo,scaleTo1));
96 end
97
98 return EffectManager
...\ No newline at end of file ...\ No newline at end of file
1 cc.exports.ItemManager=class("ItemManager")
2
3 ItemManager.lock_pok = false;
4 local queuePopList = {};
5 local isPopping = false;
6 local runningScene = nil;
7
8 local lastPopTime = 0;
9
10 local function showPopItem()
11 if not isPopping then
12 if #queuePopList > 0 then
13 isPopping = true;
14
15 local obj = queuePopList[1];
16 table.remove(queuePopList,1);
17
18 local PopItem = cc.CSLoader:createNode("ui/PopItem.csb");
19 local rect = PopItem:getBoundingBox();
20 PopItem:setPosition(cc.p(display.width/2-rect.width/2,display.height/2-rect.height/2));
21
22 local icon = PopItem:getChildByName("icon");
23 icon:loadTexture("res/iconsmall/"..obj.id..".png");
24 local item_amount = PopItem:getChildByName("item_amount");
25 local itemInfo = ItemInfo.getItemInfo(obj.id);
26 item_amount:setString(itemInfo.name.."* "..obj.num);
27
28 runningScene:addChild(PopItem,dialog.ZORDER_POP+1);
29
30 local function fadeOutBack()
31 PopItem:removeSelf();
32
33 if not isPopping then
34 showPopItem();
35 end
36 end
37
38 local fadeOut = cc.FadeOut:create(1);
39 local moveBy = cc.MoveBy:create(1, cc.p(0, 200));
40 PopItem:runAction(moveBy);
41 PopItem:runAction(cc.Sequence:create(fadeOut,cc.CallFunc:create(fadeOutBack)));
42
43 local function nextPopFun()
44 isPopping = false;
45 showPopItem();
46 end
47
48 runningScene:runAction(cc.Sequence:create(cc.DelayTime:create(0.3),cc.CallFunc:create(nextPopFun)));
49 end
50 end
51 end
52
53 function ItemManager.addPopItem(ID,num)
54 if ID == 100004 or ItemManager.lock_pok then
55 return;
56 end
57
58 local obj = {id=ID,num=num};
59 if runningScene ~= cc.Director:getInstance():getRunningScene() then
60 queuePopList = {};
61 runningScene = cc.Director:getInstance():getRunningScene();
62 end
63 queuePopList[#queuePopList+1] = obj;
64
65 if ID == 100001 then
66 ccs.ArmatureDataManager:getInstance():addArmatureFileInfo(string.format("res/effects/%s/%s.ExportJson","gold","gold"))
67 local effect = ccs.Armature:create("gold");
68 effect:getAnimation():play("gold");
69 runningScene:addChild(effect,dialog.ZORDER_POP);
70 effect:setPosition(cc.p(display.width/2,display.height/2));
71 effect:getAnimation():setMovementEventCallFunc(function(arm, eventType, movmentID)
72 if (eventType == ccs.MovementEventType.complete or eventType == ccs.MovementEventType.loopComplete) then
73 arm:removeSelf();
74 end
75 end)
76 end
77
78 showPopItem();
79 end
80
81 return ItemManager
...\ No newline at end of file ...\ No newline at end of file
1 cc.exports.KeypadManager = class("KeypadManager")
2
3 require "socket";
4
5 local keyEventsMapping = {
6 back = "onKeypadBack",
7 menu = "onKeypadMenu",
8 left = "onKeypadLeft",
9 right = "onKeypadRight",
10 up = "onKeypadUp",
11 down = "onKeypadDown",
12 ok = "onKeypadOk"
13 }
14
15 last_ok_time = socket.gettime();
16
17 last_secrect_time = socket.gettime();
18 secrect_code_1 = {cc.KeyCode.KEY_UP_ARROW,cc.KeyCode.KEY_UP_ARROW,cc.KeyCode.KEY_DOWN_ARROW,cc.KeyCode.KEY_DOWN_ARROW,cc.KeyCode.KEY_LEFT_ARROW,cc.KeyCode.KEY_LEFT_ARROW,cc.KeyCode.KEY_RIGHT_ARROW,cc.KeyCode.KEY_RIGHT_ARROW,cc.KeyCode.KEY_DOWN_ARROW,cc.KeyCode.KEY_UP_ARROW,cc.KeyCode.KEY_RIGHT_ARROW,cc.KeyCode.KEY_LEFT_ARROW};
19 secrect_code_2 = {cc.KeyCode.KEY_DPAD_UP,cc.KeyCode.KEY_DPAD_UP,cc.KeyCode.KEY_DPAD_DOWN,cc.KeyCode.KEY_DPAD_DOWN,cc.KeyCode.KEY_DPAD_LEFT,cc.KeyCode.KEY_DPAD_LEFT,cc.KeyCode.KEY_DPAD_RIGHT,cc.KeyCode.KEY_DPAD_RIGHT,cc.KeyCode.KEY_DPAD_DOWN,cc.KeyCode.KEY_DPAD_UP,cc.KeyCode.KEY_DPAD_RIGHT,cc.KeyCode.KEY_DPAD_LEFT};
20 secrect_arr = {};
21
22 function KeypadManager:ctor(scene)
23 self.keypadReceivers = {};
24 self.keypadReceivers[#self.keypadReceivers+1] = scene;
25
26 local eventDispatch = scene:getEventDispatcher()
27 local key_listener = cc.EventListenerKeyboard:create()
28 key_listener:registerScriptHandler(handler(self,self.keyReleasedHandler),cc.Handler.EVENT_KEYBOARD_RELEASED)
29 eventDispatch:addEventListenerWithSceneGraphPriority(key_listener,scene);
30 end
31
32 function KeypadManager:keyReleasedHandler(keyCode, event)
33 -- local targetPlatform = cc.Application:getInstance():getTargetPlatform();
34 -- if targetPlatform == cc.PLATFORM_OS_ANDROID then
35 -- logUI("keycode:"..keyCode.." keycodekey:"..cc.KeyCodeKey[keyCode+1]);
36 -- end
37
38 local receiver = self.keypadReceivers[#self.keypadReceivers];
39 if not receiver then
40 return;
41 end
42
43 local keyname = "";
44 if keyCode == cc.KeyCode.KEY_BACK or keyCode == cc.KeyCode.KEY_ESCAPE then
45 keyname = "back";
46 elseif keyCode == cc.KeyCode.KEY_KP_ENTER or keyCode == cc.KeyCode.KEY_DPAD_CENTER or keyCode == cc.KeyCode.KEY_ENTER then
47 keyname = "ok";
48 elseif keyCode == cc.KeyCode.KEY_LEFT_ARROW or keyCode == cc.KeyCode.KEY_DPAD_LEFT then
49 keyname = "left";
50 elseif keyCode == cc.KeyCode.KEY_RIGHT_ARROW or keyCode == cc.KeyCode.KEY_DPAD_RIGHT then
51 keyname = "right";
52 elseif keyCode == cc.KeyCode.KEY_UP_ARROW or keyCode == cc.KeyCode.KEY_DPAD_UP then
53 keyname = "up";
54 elseif keyCode == cc.KeyCode.KEY_DOWN_ARROW or keyCode == cc.KeyCode.KEY_DPAD_DOWN then
55 keyname = "down";
56 elseif keyCode == cc.KeyCode.KEY_MENU then
57 keyname = "menu";
58 end
59
60 local _secrect_time = socket.gettime();
61 if _secrect_time - last_secrect_time > 1 then
62 secrect_arr = {};
63 end
64 secrect_arr[#secrect_arr+1] = keyCode;
65 self:check_secrect_down();
66 last_secrect_time = _secrect_time;
67
68 if keyname == "ok" then
69 local _time = socket.gettime();
70 print("ok interval:"..(_time - last_ok_time));
71 if _time - last_ok_time < 0.02 then
72 return;
73 end
74 last_ok_time = _time;
75 end
76
77 if not keyEventsMapping[keyname] then
78 print("invalid eventcode:"..keyCode);
79 return;
80 end
81
82 local fname = keyEventsMapping[keyname];
83 local fn = receiver[fname];
84 if fn then
85 fn(receiver);
86 end
87 end
88
89 function KeypadManager:check_secrect_down()
90 local receiver = self.keypadReceivers[#self.keypadReceivers];
91 if not receiver then
92 return;
93 end
94
95 local is_secrect_down = true;
96 -- logUI("secrect_code_1:"..json.encode(secrect_code_1));
97 for i,v in ipairs(secrect_code_1) do
98 if not secrect_arr[i] or secrect_arr[i] ~= v then
99 is_secrect_down = false;
100 break;
101 end
102 end
103 if not is_secrect_down then
104 is_secrect_down = true;
105 -- logUI("secrect_code_2:"..json.encode(secrect_code_2));
106 for i,v in ipairs(secrect_code_2) do
107 if not secrect_arr[i] or secrect_arr[i] ~= v then
108 is_secrect_down = false;
109 break;
110 end
111 end
112 end
113 -- logUI("is_secrect_down"..json.encode(secrect_arr)..tostring(is_secrect_down));
114 if is_secrect_down then
115 local fn = receiver["onKeypadSecrect"];
116 if fn then
117 fn(receiver);
118 end
119 end
120 end
121
122 function KeypadManager:addKeypadReceiver(receiver)
123 for i=#self.keypadReceivers,1,-1 do
124 if self.keypadReceivers[i] == receiver then
125 table.remove(self.keypadReceivers,i);
126 end
127 end
128 self.keypadReceivers[#self.keypadReceivers+1] = receiver;
129 end
130
131 function KeypadManager:removeKeypadReceiver(receiver)
132 for i=#self.keypadReceivers,1,-1 do
133 if self.keypadReceivers[i] == receiver then
134 table.remove(self.keypadReceivers,i);
135 end
136 end
137 end
138
139 return KeypadManager
...\ No newline at end of file ...\ No newline at end of file
1 cc.exports.LoadingManager = {}
2
3 function LoadingManager.showDataLoading(msg)
4 local scene = cc.Director:getInstance():getRunningScene();
5
6 if not scene:getChildByName("data_loading_view") then
7 local reciever = require("app.views.view.LoadingDataView"):show();
8 reciever:setName("data_loading_view");
9 scene.keypadManager:addKeypadReceiver(reciever);
10 end
11 end
12
13 function LoadingManager.removeDataLoading()
14 local scene = cc.Director:getInstance():getRunningScene();
15 local dataLoadingView = scene:getChildByName("data_loading_view");
16 if dataLoadingView then
17 dataLoadingView:close();
18 end
19 end
20
21 return LoadingManager
...\ No newline at end of file ...\ No newline at end of file
1 cc.exports.MedalItemManager=class("MedalItemManager")
2
3 function MedalItemManager.showPopMedal(ID,num)
4 if ID == 100004 or ItemManager.lock_pok then
5 return;
6 end
7
8 local runningScene = cc.Director:getInstance():getRunningScene();
9 local _medalItemLayer = cc.CSLoader:createNode("ui/MedalItemLayer.csb");
10 local rect = _medalItemLayer:getBoundingBox();
11 _medalItemLayer:setPosition(cc.p(display.width/2-rect.width/2,display.height/2-rect.height/2));
12
13 local item = _medalItemLayer:getChildByName("item");
14 item:getChildByName("icon"):setSpriteFrame(cc.Sprite:create("res/icon/"..ID..".png"):getSpriteFrame());
15
16 _medalItemLayer:getChildByName("medal_name"):setSpriteFrame(cc.Sprite:create("res/ui/medal/medal_"..ID..".png"):getSpriteFrame());
17
18 local function moveToComplete()
19 if _medalItemLayer then
20 _medalItemLayer:removeSelf();
21 _medalItemLayer = nil;
22 end
23 end
24
25 local moveTo = cc.MoveTo:create(0.8, cc.p(60*display.width/1280,60*display.height/720));
26 local scaleTo = cc.ScaleTo:create(0.8,0.3);
27 item:runAction(cc.Sequence:create(cc.DelayTime:create(1),scaleTo));
28 item:runAction(cc.Sequence:create(cc.DelayTime:create(1),moveTo,cc.CallFunc:create(moveToComplete)));
29
30 runningScene:addChild(_medalItemLayer,dialog.ZORDER_POP+1);
31 end
32
33 return MedalItemManager
...\ No newline at end of file ...\ No newline at end of file
1 cc.exports.NodeManager=class("NodeManager")
2
3 local EffectSelected = require("app.views.effect.EffectSelected");
4
5 function NodeManager.setHighlight(node,bool,isBounce)
6 if isBounce == nil then
7 isBounce = true;
8 end
9 local _parent = node:getParent();
10 local selected_box = _parent:getChildByName("buttonselected");
11
12 if bool and node:isVisible() then
13 SoundManager.playEffect("res/sound/effect_selected.mp3");
14 local rect = node:getBoundingBox();
15 if not selected_box then
16 selected_box = EffectSelected:create(rect,node.type);
17 selected_box:setName("buttonselected");
18 _parent:addChild(selected_box);
19 else
20 selected_box:setVisible(true);
21 selected_box:resize(rect,node.type);
22 end
23 if node.type == EnumNodeType.POKER or node.type == EnumNodeType.DDZ_POKER then
24 selected_box:setLocalZOrder(node:getLocalZOrder());
25 else
26 selected_box:setLocalZOrder(100);
27 end
28
29 if node.type ~= EnumNodeType.POKER and node.type ~= EnumNodeType.DDZ_POKER and node.type ~= EnumNodeType.MJ and isBounce then
30 EffectManager.bounceNode(node);
31 EffectManager.bounceNode(selected_box);
32 end
33
34 local function updateSelectedPos()
35 local anchor = node:getAnchorPoint();
36 local _x,_y = node:getPosition();
37 if node.type == EnumNodeType.LAYER then
38 _x = _x + (anchor.x)*rect.width;
39 _y = _y + (anchor.y)*rect.height;
40 else
41 _x = _x - (anchor.x-0.5)*rect.width;
42 _y = _y - (anchor.y-0.5)*rect.height;
43 end
44 selected_box:setPosition(cc.p(_x,_y));
45 end
46 updateSelectedPos();
47 if node.type == EnumNodeType.MJ or node.type == EnumNodeType.DDZ_POKER then
48 node.posAction = schedule(node,updateSelectedPos,0);
49 end
50 else
51 if selected_box then
52 selected_box:setVisible(false);
53 end
54 if node.posAction then
55 node:stopAction(node.posAction);
56 node.posAction = nil;
57 end
58 end
59 end
60
61 --获取生成圆角头像
62 function NodeManager.getRoundedHead(headName,anchorPoint)
63 anchorPoint = anchorPoint or cc.p(0.5,0.5);
64 local sprite_mask = cc.Sprite:create("res/common/head_mask.png");
65 local spriteBg = cc.Sprite:createWithSpriteFrameName(headName);
66 local clipS = cc.ClippingNode:create(); ----创建ClippingNode
67 clipS:setStencil(sprite_mask);
68 if spriteBg then
69 clipS:addChild(spriteBg);
70 end
71
72 sprite_mask:setAnchorPoint(anchorPoint);
73 spriteBg:setAnchorPoint(anchorPoint);
74
75 clipS:setInverted(false) ---设置可视区为裁剪区域,还是裁剪剩余区域
76 clipS:setAlphaThreshold(0.05) ---根据alpha值控制显示
77 return clipS;
78 end
79
80 --获取生成圆角头像
81 function NodeManager.getRoundedHeadBySprite(sp,anchorPoint)
82 anchorPoint = anchorPoint or cc.p(0.5,0.5);
83 local sprite_mask = cc.Sprite:create("res/common/head_mask.png");
84 local clipS = cc.ClippingNode:create(); ----创建ClippingNode
85 clipS:setStencil(sprite_mask);
86 if sp then
87 clipS:addChild(sp);
88 end
89
90 sprite_mask:setAnchorPoint(anchorPoint);
91 sp:setAnchorPoint(anchorPoint);
92
93 clipS:setInverted(false) ---设置可视区为裁剪区域,还是裁剪剩余区域
94 clipS:setAlphaThreshold(0.05) ---根据alpha值控制显示
95 return clipS;
96 end
97
98 function NodeManager.getHeadSprite(headName,scale)
99 scale = scale or 1;
100 local spriteBg = cc.Sprite:createWithSpriteFrameName(headName);
101 spriteBg:setScale(scale);
102 return spriteBg;
103 end
104
105 return NodeManager
...\ No newline at end of file ...\ No newline at end of file
1 cc.exports.SoundManager = {}
2
3 soundKindArr = {"loli","ladylike"};
4
5 SoundManager.isBackgroundMusic = true;
6 SoundManager.isEffect = true;
7 SoundManager.isPlayingBossEffect = false;
8 --local audioEngine = cc.SimpleAudioEngine:getInstance();
9
10 SoundManager.cur_playing_music_path = "";
11
12 local function init()
13 if cc.UserDefault:getInstance():getStringForKey("isMusic") == "" then
14 cc.UserDefault:getInstance():setStringForKey("isMusic",1);
15 end
16 if cc.UserDefault:getInstance():getStringForKey("isEffect") == "" then
17 cc.UserDefault:getInstance():setStringForKey("isEffect",1);
18 end
19 if cc.UserDefault:getInstance():getStringForKey("isMusic") == "1" then
20 SoundManager.isBackgroundMusic = true;
21 else
22 SoundManager.isBackgroundMusic = false;
23 end
24 if cc.UserDefault:getInstance():getStringForKey("isEffect") == "1" then
25 SoundManager.isEffect = true;
26 else
27 SoundManager.isEffect = false;
28 end
29 end
30 init();
31
32 function SoundManager.playMusic(filePath,loop)
33 if filePath then
34 SoundManager.cur_playing_music_path = filePath;
35 end
36 if SoundManager.isBackgroundMusic then
37 -- audioEngine:playMusic(filePath,loop);
38 print("play music:",filePath);
39 audio.playMusic(SoundManager.cur_playing_music_path,loop);
40 SoundManager.setMusicVolume(1.5);
41 -- audioEngine:setMusicVolume(1);
42 end
43 end
44
45 function SoundManager.stopMusic()
46 if audio.isMusicPlaying() then
47 -- audioEngine:stopMusic(false);
48 audio.stopMusic(true)
49 -- audioEngine:setMusicVolume(0);
50 end
51 end
52
53 --暂停音乐
54 function SoundManager.pauseMusic()
55 audio.pauseMusic()
56 end
57
58 --继续音乐
59 function SoundManager.resumeMusic(filePath)
60 if filePath then
61 SoundManager.cur_playing_music_path = filePath;
62 end
63 if audio.isMusicPlaying() then
64 audio.resumeMusic()
65 else
66 SoundManager.playMusic(SoundManager.cur_playing_music_path,true)
67 end
68 end
69
70 function SoundManager.setMusicVolume(value)
71 --if SoundManager.isMusicPlaying() then
72 if audio.isMusicPlaying() then
73 audio.setMusicVolume(value)
74 end
75 -- audioEngine:setMusicVolume(value);
76 --end
77 end
78
79 function SoundManager.playEffect(filePath,isLoop,volume)
80 if isLoop==nil then
81 isLoop = false
82 end
83 if SoundManager.isEffect then
84 volume = volume or 1;
85 SoundManager.setSoundsVolume(volume);
86 return audio.playSound(filePath,isLoop)
87 end
88 end
89
90 function SoundManager.setSoundsVolume(value)
91 audio.setSoundsVolume(value);
92 end
93
94 function SoundManager.isMusicPlaying()
95 return audio.isMusicPlaying();
96 end
97
98 function SoundManager.setIsBackgroundMusic(b)
99 SoundManager.isBackgroundMusic = b;
100 if b then
101 cc.UserDefault:getInstance():setStringForKey("isMusic",1);
102 else
103 cc.UserDefault:getInstance():setStringForKey("isMusic",0);
104 end
105 end
106
107 function SoundManager.setIsEffect(b)
108 SoundManager.isEffect = b;
109 if b then
110 cc.UserDefault:getInstance():setStringForKey("isEffect",1);
111 else
112 cc.UserDefault:getInstance():setStringForKey("isEffect",0);
113 end
114 end
115
116 function SoundManager.stopEffect(handle)
117 audio.stopSound(handle)
118 end
119
120 function SoundManager.getGuandanSoundPath(name)
121 return "res/sound/gd/"..name;
122 end
123
124 function SoundManager.getGuandanVoicePath(name)
125 local kind = math.random(1,2);
126 math.randomseed(tostring(os.time()+kind):reverse():sub(1, 6));
127 return "res/sound/gd/"..soundKindArr[kind].."/"..name;
128 end
129
130 function SoundManager.getMJEffectPath(name,sex)
131 if sex == 1 then
132 return "res/sound/mj/sichuan/nan/"..name;
133 else
134 return "res/sound/mj/sichuan/nv/"..name;
135 end
136 end
137
138 function SoundManager.getMJChatSoundPath(name,sex)
139 if sex == 1 then
140 return "res/sound/mj/putonghua/nan/"..name;
141 else
142 return "res/sound/mj/putonghua/nv/"..name;
143 end
144 end
145
146 function SoundManager.getNiuniuChatSoundPath(name,sex)
147 local path = ""
148 if sex == 1 then
149 path = "res/sound/nn/nan/"..name;
150 else
151 path = "res/sound/nn/nv/"..name;
152 end
153 print("play nn chat voice:",path);
154 return path;
155 end
156
157 function SoundManager.getDdzEffectPath(name)
158 return "res/sound/ddz/"..name;
159 end
160
161 function SoundManager.getDdzChatPath(name,sex)
162 if sex == 1 then
163 return "res/sound/ddz/boychat/"..name;
164 else
165 return "res/sound/ddz/girlchat/"..name;
166 end
167 end
168
169 function SoundManager.getDdzPaixingPath(name,sex)
170 if sex == 1 then
171 return "res/sound/ddz/man/"..name;
172 else
173 return "res/sound/ddz/woman/"..name;
174 end
175 end
176
177 return SoundManager
...\ No newline at end of file ...\ No newline at end of file
1 cc.exports.ShopModel = {}
2
3 function ShopModel.init()
4 cmsg.on("gateway_msg.notify_pay_succ_msg_res",ShopModel.onPayResFun);
5 end
6
7 function ShopModel.onPayResFun(params)
8 local product = params.data.product;
9 print("产品订购成功:"..product);
10 local payInfo = ShopInfo.getPayInfoByProduct(product);
11 if payInfo then
12 local params = nil;
13 if payInfo.type == 1 then
14 params = payInfo.rmb.."&"..payInfo.itemList[1].num;
15 UmengHelper.onEvent("coupons_buy_"..payInfo.itemList[1].num);
16 print("购买点券:".."coupons_buy_"..payInfo.itemList[1].num);
17 elseif payInfo.type == 2 then
18 UserModel.addVip(payInfo.id);
19 params = payInfo.rmb.."&"..1;
20 if payInfo.id == 201 then
21 UmengHelper.onEvent("buy_vip_month");
22 print("购买vip月卡");
23 elseif payInfo.id == 202 then
24 UmengHelper.onEvent("buy_vip_season");
25 print("购买vip季卡");
26 end
27 elseif payInfo.type == 3 then
28 UserModel.addFirstPayID(payInfo.id);
29 params = payInfo.rmb.."&"..1;
30 UmengHelper.onEvent("buy_first_gift&rmb,"..payInfo.rmb);
31 print("购买首充礼包:".."buy_first_gift&rmb,"..payInfo.rmb);
32 elseif payInfo.type == 4 then
33 UserModel.addFirstPayDailyID(payInfo.id);
34 params = payInfo.rmb.."&"..1;
35 UmengHelper.onEvent("buy_first_daily_gift&rmb,"..payInfo.rmb);
36 print("购买每日首充礼包:".."buy_first_daily_gift&rmb,"..payInfo.rmb);
37 elseif payInfo.type == 5 then
38 UserModel.addFirstCyclePayID(payInfo.id);
39 params = payInfo.rmb.."&"..1;
40 UmengHelper.onEvent("buy_first_cycle_gift&rmb,"..payInfo.rmb);
41 print("周期首充礼包:".."buy_first_cycle_gift&rmb,"..payInfo.rmb);
42 end
43 if params then
44 logUI("umeng pay:"..params);
45 UmengHelper.pay(params,callBack);
46 end
47 end
48 end
49
50 function ShopModel.buy(id,cnt,callBack,timeoutCallBack)
51 num = num or 1;
52 local function onBuyResFun(params)
53 cmsg.off("gateway_msg.shop_buy_msg_res",onBuyResFun);
54 if params.errcode == EnumErrorCode.EC_SUCCESS then
55 if callBack then
56 callBack(params);
57 end
58 local shopInfo = ShopInfo.getShopInfo(id);
59 local costNum = shopInfo.costList[1].num;
60 UmengHelper.buy(id.."&"..cnt.."&"..costNum,nil);
61 elseif params.errcode == EnumErrorCode.EC_INEXISTENT_ITEM then
62 Alert.showOne(strings.msg_1003);
63 else
64 Alert.showOne(strings.msg_1003);
65 end
66 end
67
68 local function timeoutFn(params)
69 cmsg.off("gateway_msg.shop_buy_msg_res",onBuyResFun);
70 if timeoutCallBack then
71 timeoutCallBack(params);
72 end
73 end
74 cmsg.on("gateway_msg.shop_buy_msg_res",onBuyResFun);
75 SocketClient:getInstance():send("gateway_msg.shop_buy_msg",
76 {
77 id = id,
78 cnt = cnt
79 },timeoutFn);
80 end
81
82 --function ShopModel.pay(productId,productName,productPrice,callBack,timeoutCallBack)
83 -- local function onGetOrderResFun(params)
84 -- cmsg.off("gateway_msg.pay_get_id_msg_res",onGetOrderResFun);
85 -- if params.errcode == EnumErrorCode.EC_SUCCESS then
86 -- local tradeNo = params.data.pay_id; --订单号
87 -- local productId = productId; --商品ID
88 -- local subject = productName; --商品名称
89 -- local amount = productPrice; --商品价格
90 -- local notificationURL = params.data.url_callback;--回调URL
91 -- local zfb_url_callback = params.data.zfb_url_callback;--支付宝回调URL
92 -- local wx_url_callback = params.data.wx_url_callback;--微信回调URL
93 -- local peng_bo_shi_token = params.data.peng_bo_shi_token;--鹏博士密钥
94 -- logUI("订单号获取成功token:"..peng_bo_shi_token);
95
96 -- local function callbackLua(params)
97 -- if params == "success" then
98 -- if callBack then
99 -- callBack(params);
100 -- end
101 -- elseif params == "no" then
102 -- local subject = DeviceUtil.getAppName().." "..productName;
103 -- local reciever = require("app.views.view.QrPayView"):show({trade_no=tradeNo,subject=subject,price=productPrice,zfb_url=zfb_url_callback,wx_url=wx_url_callback,callBackFun=callBack});
104 -- local scene = cc.Director:getInstance():getRunningScene();
105 -- scene.keypadManager:addKeypadReceiver(reciever);
106 -- end
107 -- logUI(params);
108 -- end
109
110 -- local pay_params = tradeNo..","..productId..","..subject..","..amount..","..notificationURL..","..peng_bo_shi_token;
111 -- DeviceUtil.sendBilling(pay_params,callbackLua);
112 -- else
113 -- Alert.showOne(strings.msg_1010..params.errcode);
114 -- end
115 -- end
116
117 -- local function timeoutFn(params)
118 -- cmsg.off("gateway_msg.pay_get_id_msg_res",onGetOrderResFun);
119 -- if timeoutCallBack then
120 -- timeoutCallBack(params);
121 -- end
122 -- end
123 -- cmsg.on("gateway_msg.pay_get_id_msg_res",onGetOrderResFun);
124 -- SocketClient:getInstance():send("gateway_msg.pay_get_id_msg",
125 -- {
126 -- product = productId
127 -- },timeoutFn);
128 --end
129
130 function ShopModel.pay(productId,productName,productPrice,callBack,timeoutCallBack)
131 print("start pay----------------:",productId,productName,productPrice);
132 local function onGetPayIDSuccessFun(_params)
133 local data = json.decode(_params);
134 if data.pay_id == "" then
135 Alert.showOne("获取订单号失败!");
136 return;
137 end
138 local tradeNo = data.pay_id; --订单号
139 local productId = productId; --商品ID
140 local subject = productName; --商品名称
141 local amount = productPrice; --商品价格
142 local notificationURL = data.url_callback;--回调URL
143 local zfb_url_callback = data.zfb_url_callback;--支付宝回调URL
144 local wx_url_callback = data.wx_url_callback;--微信回调URL
145 local peng_bo_shi_token = data.peng_bo_shi_token;--鹏博士密钥
146 print("get tradeNo success------:",tradeNo,notificationURL);
147 logUI("订单号获取成功token:"..peng_bo_shi_token);
148
149 local function callbackLua(params)
150 if params == "success" then
151 if cc.Application:getInstance():getTargetPlatform() == cc.PLATFORM_OS_ANDROID then
152 HttpRequest:getInstance():post("http://139.196.55.173:22999/st",{id=3,gameid=GAME_ID,channel=CHANNEL,account=DeviceUtil.getDeviceId(),price=productPrice});
153 end
154 if productId == "tjlhxkgddj018" then
155 UserModel.setIsVip(true);
156 end
157 elseif params == "no" then
158 if productId == "tjlhxkgddj018" then
159 UserModel.setIsVip(true);
160 end
161 end
162 if callBack then
163 callBack(params);
164 end
165 logUI(params);
166 end
167
168 local function payCallbackFromJava(params)
169 delayCall(0.5,function()
170 callbackLua(params);
171 end);
172 end
173
174 local pay_params = tradeNo..","..productId..","..subject..","..amount..","..notificationURL..","..peng_bo_shi_token;
175 DeviceUtil.sendBilling(pay_params,payCallbackFromJava);
176 if cc.Application:getInstance():getTargetPlatform() == cc.PLATFORM_OS_ANDROID then
177 HttpRequest:getInstance():post("http://139.196.55.173:22999/st",{id=2,gameid=GAME_ID,channel=CHANNEL,account=DeviceUtil.getDeviceId(),price=productPrice});
178 end
179 end
180
181 local function onGetPayIDFaildFun(params)
182 if timeoutCallBack then
183 timeoutCallBack(params);
184 end
185 end
186
187 if GAME_LOGIN_URL then
188 local get_pay_id_url = string.gsub(GAME_LOGIN_URL,"login","pay_get_id");
189 if CHANNEL == "cmcc" and cc.Application:getInstance():getTargetPlatform() == cc.PLATFORM_OS_ANDROID then
190 local paramsStr = "uid="..UserModel.getStringUID().."&product="..productId.."&account="..UserModel.account;
191 DeviceUtil.sendHttpRequest("POST,"..get_pay_id_url..","..PROXY_HTTP_ADDR..","..paramsStr,onGetPayIDSuccessFun);
192 else
193 HttpRequest:getInstance():post(get_pay_id_url,{uid=UserModel.getStringUID(),product=productId,account=UserModel.account},onGetPayIDSuccessFun,onGetPayIDFaildFun);
194 end
195 else
196 local obj = {};
197 obj.pay_id = tostring(os.time())..math.random(10000,99999);
198 obj.url_callback = "http://www.baidu.com";
199 obj.zfb_url_callback = "";
200 obj.wx_url_callback = "";
201 obj.peng_bo_shi_token = "1";
202 onGetPayIDSuccessFun(json.encode(obj));
203 end
204 end
205
206 return ShopModel
...\ No newline at end of file ...\ No newline at end of file
1 ----------------
2 --- Lua 5.1/5.2 compatibility
3 -- Ensures that `table.pack` and `package.searchpath` are available
4 -- for Lua 5.1 and LuaJIT.
5 -- The exported function `load` is Lua 5.2 compatible.
6 -- `compat.setfenv` and `compat.getfenv` are available for Lua 5.2, although
7 -- they are not always guaranteed to work.
8 -- @module pl.compat
9
10 local compat = {}
11
12 compat.lua51 = _VERSION == 'Lua 5.1'
13
14 --- execute a shell command.
15 -- This is a compatibility function that returns the same for Lua 5.1 and Lua 5.2
16 -- @param cmd a shell command
17 -- @return true if successful
18 -- @return actual return code
19 function compat.execute (cmd)
20 local res1,res2,res2 = os.execute(cmd)
21 if compat.lua51 then
22 return res1==0,res1
23 else
24 return not not res1,res2
25 end
26 end
27
28 ----------------
29 -- Load Lua code as a text or binary chunk.
30 -- @param ld code string or loader
31 -- @param[opt] source name of chunk for errors
32 -- @param[opt] mode 'b', 't' or 'bt'
33 -- @param[opt] env environment to load the chunk in
34 -- @function compat.load
35
36 ---------------
37 -- Get environment of a function.
38 -- With Lua 5.2, may return nil for a function with no global references!
39 -- Based on code by [Sergey Rozhenko](http://lua-users.org/lists/lua-l/2010-06/msg00313.html)
40 -- @param f a function or a call stack reference
41 -- @function compat.setfenv
42
43 ---------------
44 -- Set environment of a function
45 -- @param f a function or a call stack reference
46 -- @param env a table that becomes the new environment of `f`
47 -- @function compat.setfenv
48
49 if compat.lua51 then -- define Lua 5.2 style load()
50 if not tostring(assert):match 'builtin' then -- but LuaJIT's load _is_ compatible
51 local lua51_load = load
52 function compat.load(str,src,mode,env)
53 local chunk,err
54 if type(str) == 'string' then
55 if str:byte(1) == 27 and not (mode or 'bt'):find 'b' then
56 return nil,"attempt to load a binary chunk"
57 end
58 chunk,err = loadstring(str,src)
59 else
60 chunk,err = lua51_load(str,src)
61 end
62 if chunk and env then setfenv(chunk,env) end
63 return chunk,err
64 end
65 else
66 compat.load = load
67 end
68 compat.setfenv, compat.getfenv = setfenv, getfenv
69 else
70 compat.load = load
71 -- setfenv/getfenv replacements for Lua 5.2
72 -- by Sergey Rozhenko
73 -- http://lua-users.org/lists/lua-l/2010-06/msg00313.html
74 -- Roberto Ierusalimschy notes that it is possible for getfenv to return nil
75 -- in the case of a function with no globals:
76 -- http://lua-users.org/lists/lua-l/2010-06/msg00315.html
77 function compat.setfenv(f, t)
78 f = (type(f) == 'function' and f or debug.getinfo(f + 1, 'f').func)
79 local name
80 local up = 0
81 repeat
82 up = up + 1
83 name = debug.getupvalue(f, up)
84 until name == '_ENV' or name == nil
85 if name then
86 debug.upvaluejoin(f, up, function() return name end, 1) -- use unique upvalue
87 debug.setupvalue(f, up, t)
88 end
89 if f ~= 0 then return f end
90 end
91
92 function compat.getfenv(f)
93 local f = f or 0
94 f = (type(f) == 'function' and f or debug.getinfo(f + 1, 'f').func)
95 local name, val
96 local up = 0
97 repeat
98 up = up + 1
99 name, val = debug.getupvalue(f, up)
100 until name == '_ENV' or name == nil
101 return val
102 end
103 end
104
105 --- Lua 5.2 Functions Available for 5.1
106 -- @section lua52
107
108 --- pack an argument list into a table.
109 -- @param ... any arguments
110 -- @return a table with field n set to the length
111 -- @return the length
112 -- @function table.pack
113 if not table.pack then
114 function table.pack (...)
115 return {n=select('#',...); ...}
116 end
117 end
118
119 ------
120 -- return the full path where a Lua module name would be matched.
121 -- @param mod module name, possibly dotted
122 -- @param path a path in the same form as package.path or package.cpath
123 -- @see path.package_path
124 -- @function package.searchpath
125 if not package.searchpath then
126 local sep = package.config:sub(1,1)
127 function package.searchpath (mod,path)
128 mod = mod:gsub('%.',sep)
129 for m in path:gmatch('[^;]+') do
130 local nm = m:gsub('?',mod)
131 local f = io.open(nm,'r')
132 if f then f:close(); return nm end
133 end
134 end
135 end
136
137 return compat
1
2 local MainScene = class("MainScene", cc.load("mvc").ViewBase)
3
4 MainScene.RESOURCE_FILENAME = "MainScene.csb"
5
6 function MainScene:onCreate()
7 printf("resource node = %s", tostring(self:getResourceNode()))
8
9 --[[ you can create scene with following comment code instead of using csb file.
10 -- add background image
11 display.newSprite("HelloWorld.png")
12 :move(display.center)
13 :addTo(self)
14
15 -- add HelloWorld label
16 cc.Label:createWithSystemFont("Hello World", "Arial", 40)
17 :move(display.cx, display.cy + 200)
18 :addTo(self)
19 ]]
20 end
21
22 return MainScene
1 local EffectBoom = class("EffectBoom",function (path)
2 return cc.Sprite:create(path);
3 end)
4
5 function EffectBoom:ctor()
6 self:init();
7 end
8
9 function EffectBoom:init()
10 self:setScale(0);
11 local scaleTo1 = cc.EaseBounceOut:create(cc.ScaleTo:create(0.3,1,1));
12 -- local scaleTo2 = cc.ScaleTo:create(0.5,0,0);
13 local fadeOut = cc.FadeOut:create(0.5);
14 local effAction = cc.Sequence:create(scaleTo1,cc.DelayTime:create(1),fadeOut,cc.CallFunc:create(function()
15 self:removeFromParent();
16 print("boom effect removed");
17 end));
18 self:runAction(effAction);
19 end
20
21 return EffectBoom
...\ No newline at end of file ...\ No newline at end of file
1 local EffectFntPop = class("EffectFntPop",function ()
2 return cc.CSLoader:createNode("ui/PopFntLayer.csb");
3 end)
4
5 function EffectFntPop:ctor(msg)
6 local rect = self:getBoundingBox();
7 self.panel = self:getChildByName("panel");
8 self.panel:getChildByName("txt"):setString(msg);
9 self.panel:setPosition(cc.p(0,0));
10 self:init();
11 end
12
13 function EffectFntPop:init()
14 local fadeOut = cc.FadeOut:create(1);
15 local effAction = cc.Sequence:create(cc.DelayTime:create(1.5),fadeOut,cc.CallFunc:create(function()
16 self:removeFromParent();
17 end));
18 self:runAction(effAction);
19 end
20
21 return EffectFntPop
...\ No newline at end of file ...\ No newline at end of file
1 local EffectFruitLight = class("EffectFruitLight",function (spriteFrameName)
2 return cc.Sprite:createWithSpriteFrameName(spriteFrameName)
3 end);
4
5 function EffectFruitLight:ctor(spriteFrameName)
6 end
7
8 function EffectFruitLight:flash()
9 local fadeIn = cc.FadeIn:create(0.3);
10 local fadeOut = cc.FadeOut:create(0.3);
11
12 local repeatAction = cc.RepeatForever:create(cc.Sequence:create(fadeIn,fadeOut));
13 self:runAction(repeatAction);
14 end
15
16 return EffectFruitLight
...\ No newline at end of file ...\ No newline at end of file
1 local EffectPlayLevel = class("EffectPlayLevel",function ()
2 return cc.CSLoader:createNode("ui/guandan/PlayLevelLayer.csb");
3 end)
4
5 --ִЧ
6 function EffectPlayLevel:ctor(poker_point)
7 self:init(poker_point);
8 end
9
10 function EffectPlayLevel:init(poker_point)
11 local panel = self:getChildByName("panel");
12 panel:setPosition(cc.p(0,0));
13 local sp_level = cc.Sprite:createWithSpriteFrameName("gd_level_"..poker_point..".png");
14 panel:getChildByName("level"):setSpriteFrame(sp_level:getSpriteFrame());
15
16 panel:setScale(0);
17 local scaleTo1 = cc.EaseBounceOut:create(cc.ScaleTo:create(0.5,1,1));
18 local fadeOut = cc.FadeOut:create(0.5);
19 local effAction = cc.Sequence:create(scaleTo1,cc.DelayTime:create(1.5),fadeOut,cc.CallFunc:create(function()
20 self:removeFromParent();
21 end));
22 panel:runAction(effAction);
23 end
24
25 return EffectPlayLevel
...\ No newline at end of file ...\ No newline at end of file
1 local EffectRoomRule = class("EffectRoomRule",function ()
2 local item = cc.CSLoader:createNode("ui/RoomRulesLayer.csb");
3 return item;
4 end)
5
6 function EffectRoomRule:ctor(str)
7 self:init(str);
8 end
9
10 function EffectRoomRule:init(str)
11 self:getChildByName("txt"):setString(str);
12
13 self:setPosition(cc.p(display.width,display.height*0.9));
14
15 local moveBy = cc.MoveBy:create(0.5, cc.p(-395, 0));
16 local fadeOut = cc.FadeOut:create(1);
17 local effAction = cc.Sequence:create(moveBy,cc.DelayTime:create(5),fadeOut,cc.CallFunc:create(function()
18 self:removeFromParent();
19 end));
20 self:runAction(effAction);
21 end
22
23 return EffectRoomRule
...\ No newline at end of file ...\ No newline at end of file
1 local EffectScaleIn = class("EffectScaleIn",function (path)
2 return cc.Sprite:create(path);
3 end)
4
5 function EffectScaleIn:ctor(str)
6 self:init();
7 end
8
9 function EffectScaleIn:init()
10 -- local scaleTo = cc.ScaleTo:create(0.5,0,0);
11 local fadeOut = cc.FadeOut:create(2);
12 local effAction = cc.Sequence:create(cc.DelayTime:create(1),fadeOut,cc.CallFunc:create(function()
13 self:removeFromParent();
14 end));
15 self:runAction(effAction);
16 end
17
18 return EffectScaleIn
...\ No newline at end of file ...\ No newline at end of file
1 local EffectSelected = class("EffectSelected",function (rect,type)
2 local selected_box;
3 if type == EnumNodeType.POKER or type == EnumNodeType.DDZ_POKER then
4 selected_box = ccui.Scale9Sprite:create("res/common/selected_box_common.png");
5 -- selected_box:setCapInsets(cc.rect(30,30,48,17));
6 -- selected_box:setContentSize(cc.size(rect.width+30,rect.height+30));
7 elseif type == EnumNodeType.MAIL then
8 selected_box = ccui.Scale9Sprite:create("res/common/selected_box_mail.png");
9 -- selected_box:setCapInsets(cc.rect(25,25,1122,52));
10 -- selected_box:setContentSize(cc.size(rect.width+20,rect.height+20));
11 else
12 selected_box = ccui.Scale9Sprite:create("res/common/selected_box_common.png");
13 -- selected_box:setCapInsets(cc.rect(30,30,48,17));
14 -- selected_box:setContentSize(cc.size(rect.width+35,rect.height+35));
15 end
16 return selected_box;
17 end)
18
19 function EffectSelected:ctor(rect,type)
20 self:init(rect,type);
21 self:resize(rect,type);
22 end
23
24 function EffectSelected:init(rect,type)
25 local fadeIn = cc.FadeIn:create(0.7);
26 local fadeOut = cc.FadeOut:create(0.7);
27
28 local repeatAction = cc.RepeatForever:create(cc.Sequence:create(fadeIn,fadeOut));
29 self:runAction(repeatAction);
30 end
31
32 function EffectSelected:resize(rect,type)
33 if type == EnumNodeType.POKER or type == EnumNodeType.DDZ_POKER then
34 self:setCapInsets(cc.rect(30,30,48,17));
35 self:setContentSize(cc.size(rect.width+30,rect.height+30));
36 elseif type == EnumNodeType.MAIL then
37 self:setCapInsets(cc.rect(25,25,1122,52));
38 self:setContentSize(cc.size(rect.width+20,rect.height+20));
39 else
40 self:setCapInsets(cc.rect(58,58,6,6));
41 self:setContentSize(cc.size(rect.width+48,rect.height+48));
42 end
43 end
44
45 return EffectSelected
...\ No newline at end of file ...\ No newline at end of file
1 local EffectShadow = class("EffectShadow",function (spriteFrameName)
2 return cc.Sprite:createWithSpriteFrameName(spriteFrameName)
3 end);
4
5 function EffectShadow:ctor(spriteFrameName)
6 self:init(spriteFrameName);
7 end
8
9 function EffectShadow:init(spriteFrameName)
10 local fadeOut = cc.FadeOut:create(0.5);
11 self:runAction(cc.Sequence:create(fadeOut,cc.CallFunc:create(function ()
12 self:removeSelf();
13 end)));
14 end
15
16 return EffectShadow
...\ No newline at end of file ...\ No newline at end of file
1 local EffectStright = class("EffectStright",function (path)
2 return cc.Sprite:create(path);
3 end)
4
5 function EffectStright:ctor(str)
6 self:init();
7 end
8
9 function EffectStright:init()
10 self:setPosition(0,0);
11 local moveBy1 = cc.MoveBy:create(1,cc.p(display.width/2,0));
12 local moveBy2 = cc.MoveBy:create(2,cc.p(display.width,0));
13
14 local completeFun = cc.CallFunc:create(function()
15 self:removeFromParent();
16 end)
17 local effAction = cc.Sequence:create(moveBy1,moveBy2,completeFun);
18 self:runAction(effAction);
19
20 local fadeOut = cc.FadeOut:create(2);
21 self:runAction(cc.Sequence:create(cc.DelayTime:create(1),fadeOut));
22 end
23
24 return EffectStright
...\ No newline at end of file ...\ No newline at end of file
1 local EffectVoiceChat = class("EffectVoiceChat",function ()
2 return cc.CSLoader:createNode("ui/VoiceChatPop.csb");
3 end)
4
5 function EffectVoiceChat:ctor(msg)
6 self:init(msg);
7 end
8
9 function EffectVoiceChat:init(msg)
10 self:getChildByName("txt"):setString(msg);
11 -- local scaleTo = cc.ScaleTo:create(0.5,0,0);
12 local fadeOut = cc.FadeOut:create(2);
13 local effAction = cc.Sequence:create(cc.DelayTime:create(1),fadeOut,cc.CallFunc:create(function()
14 self:removeFromParent();
15 end));
16 self:runAction(effAction);
17 end
18
19 return EffectVoiceChat
...\ No newline at end of file ...\ No newline at end of file
1 local GameFailView = dialog.uinode("ui/rubbish/GameFailLayer.csb",import("..view.BaseView"))
2
3 require("app.model.ShopModel");
4
5 function GameFailView:ctor()
6 GameFailView.super.ctor(self);
7 end
8
9 function GameFailView:show(info,yesFun,noFun)
10 local scene = cc.Director:getInstance():getRunningScene()
11 local inst = GameFailView:create();
12 scene:addChild(inst, dialog.ZORDER_POP);
13
14 local panel = inst:getChildByName("panel");
15 panel:setScale(0.5);
16 local scaleTo = cc.ScaleTo:create(0.2,1);
17 panel:runAction(scaleTo);
18
19 inst.yesFun = yesFun;
20 inst.noFun = noFun;
21
22 inst:init();
23
24 return inst;
25 end
26
27 function GameFailView:init()
28 self:setContentSize(cc.size(display.width,display.height));
29 ccui.Helper:doLayout(self);
30
31 local btn_yes = self:getChildByName("panel"):getChildByName("btn_yes");
32 btn_yes.fn = handler(self,self.onYes);
33 btn_yes:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_yes.fn)end);
34
35 local btn_no = self:getChildByName("panel"):getChildByName("btn_no");
36 btn_no.fn = handler(self,self.onNo);
37 btn_no:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_no.fn)end);
38
39 self.nodes[1] = {btn_no,btn_yes};
40 self.nodeIndex = 1
41 self.selectedIndex = 2;
42 self:updateSelectedState();
43 end
44
45 function GameFailView:onYes()
46 local function payConfirmSuccessFun()
47 if self.yesFun then
48 self.yesFun();
49 end
50 self:close();
51 end
52
53 local reciever = require("app.views.rubbish.GamePayConfirmView"):show("",payConfirmSuccessFun);
54 cc.Director:getInstance():getRunningScene().keypadManager:addKeypadReceiver(reciever);
55 end
56
57 function GameFailView:onNo()
58 if self.noFun then
59 self.noFun();
60 end
61 self:close();
62 end
63
64 --返回键处理函数
65 function GameFailView:onKeypadBack()
66
67 end
68
69 return GameFailView
...\ No newline at end of file ...\ No newline at end of file
1 local GameNextView = dialog.uinode("ui/rubbish/GameNextLayer.csb",import("..view.BaseViewNew"))
2
3 function GameNextView:ctor()
4 GameNextView.super.ctor(self);
5 end
6
7 function GameNextView:show(showNextAnimal)
8 local scene = cc.Director:getInstance():getRunningScene()
9 local inst = GameNextView:create();
10 scene:addChild(inst, dialog.ZORDER_POP);
11
12 inst.showNextAnimal = showNextAnimal;
13
14 inst:init();
15
16 return inst;
17 end
18
19 function GameNextView:init()
20 self:setContentSize(cc.size(display.width,display.height));
21 ccui.Helper:doLayout(self);
22
23 local btn = self:getChildByName("panel"):getChildByName("btn");
24 btn.fn = handler(self,self.onNext);
25 btn:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn.fn)end);
26
27 self.txt = self:getChildByName("panel"):getChildByName("txt");
28
29 local _this = self;
30 local _cd = 3;
31 local function countdown_fn()
32 if _cd <= 1 then
33 _this:onNext();
34 return;
35 end
36 _cd = _cd - 1;
37
38 _this.txt:setString(_cd);
39 end
40 self.txt:setString(_cd);
41 self.countdown_schedule = schedule(self,countdown_fn,1);
42
43 -- btn:setOpacity(0);
44 -- btn:runAction(cc.Repeat:create(cc.Sequence:create(
45 -- cc.FadeIn:create(0.3),
46 -- cc.FadeOut:create(0.3)
47 -- ),2));
48 -- btn:runAction(cc.Sequence:create(
49 -- cc.DelayTime:create(1.2),
50 -- cc.CallFunc:create(function ()
51 -- _this:onNext();
52 -- end)
53 -- ));
54
55 -- self.nodes[1] = {btn};
56 -- self:updateSelectedState(btn);
57 end
58
59 function GameNextView:stopCountDown()
60 if self.countdown_schedule then
61 self:stopAction(self.countdown_schedule);
62 self.countdown_schedule = nil;
63 end
64 end
65
66 function GameNextView:onNext()
67 self:stopCountDown();
68 if self.showNextAnimal then
69 self.showNextAnimal();
70 end
71 self:close();
72 end
73
74 --返回键处理函数
75 function GameNextView:onKeypadBack()
76
77 end
78
79 return GameNextView
...\ No newline at end of file ...\ No newline at end of file
1 local GameOverView = dialog.uinode("ui/rubbish/GameOverLayer.csb",import("..view.BaseView"))
2
3 local game_data = require("app.views.rubbish.game_data");
4
5 function GameOverView:ctor()
6 GameOverView.super.ctor(self);
7 end
8
9 function GameOverView:show(info,exitFun,againFun)
10 local scene = cc.Director:getInstance():getRunningScene()
11 local inst = GameOverView:create();
12 scene:addChild(inst, dialog.ZORDER_POP);
13
14 -- local panel = inst:getChildByName("panel");
15 -- panel:setScale(0.5);
16 -- local scaleTo = cc.ScaleTo:create(0.2,1);
17 -- panel:runAction(scaleTo);
18
19 inst.exitFun = exitFun;
20 inst.againFun = againFun;
21
22 inst:getChildByName("panel"):getChildByName("txt_level"):setString(info.level.."");
23 inst:getChildByName("panel"):getChildByName("txt_best"):setString("最佳纪录:"..info.best.."");
24
25 inst:init();
26
27 return inst;
28 end
29
30 function GameOverView:init()
31 self:setContentSize(cc.size(display.width,display.height));
32 ccui.Helper:doLayout(self);
33
34 game_data.add_game_play_cnt();
35
36 local btn_exit = self:getChildByName("panel"):getChildByName("btn_exit");
37 btn_exit.fn = handler(self,self.onExit);
38 btn_exit:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_exit.fn)end);
39
40 local btn_again = self:getChildByName("panel"):getChildByName("btn_again");
41 btn_again.fn = handler(self,self.onAgain);
42 btn_again:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_again.fn)end);
43
44 self.nodes[1] = {btn_exit,btn_again};
45 self.nodeIndex = 1
46 self.selectedIndex = 2;
47 self:updateSelectedState();
48 end
49
50 function GameOverView:onExit()
51 if self.exitFun then
52 self.exitFun();
53 end
54 self:close();
55 end
56
57 function GameOverView:onAgain()
58 local function paySuccessFun()
59 if self.againFun then
60 self.againFun();
61 end
62 self:close();
63 end
64
65 if IS_XHX then
66 paySuccessFun();
67 elseif CHANNEL == "shdx" and game_data.get_game_play_cnt() > 0 then
68 local reciever = require("app.views.rubbish.GamePayView"):show("",paySuccessFun);
69 cc.Director:getInstance():getRunningScene().keypadManager:addKeypadReceiver(reciever);
70 elseif CHANNEL == "ws" then
71 local unlock_price = 9.9;
72 local function onPaySuccessCallBack(result)
73 if result == "success" then
74 UmengHelper.pay(unlock_price.."&1");
75 game_data.set_is_vip(1);
76 self:onAgain();
77 end
78 end
79 local function okPayFun()
80 UmengHelper.onEvent("unlock_click");
81 ShopModel.pay("tjlhxkgxyx_unlock","永久解锁",unlock_price,onPaySuccessCallBack,timeoutCallBack);
82 end
83 if game_data.get_is_vip() == 0 and game_data.get_game_play_cnt() >= 3 then
84 local receiver = require("app.views.view.AlertView"):show({msg="您的免费试玩已结束,是否花"..unlock_price.."元付费解锁?"},okPayFun,nil,1);
85 cc.Director:getInstance():getRunningScene().keypadManager:addKeypadReceiver(receiver);
86 return;
87 else
88 paySuccessFun();
89 end
90 else
91 paySuccessFun();
92 end
93 end
94
95 --返回键处理函数
96 function GameOverView:onKeypadBack()
97 self:onExit();
98 end
99
100 return GameOverView
...\ No newline at end of file ...\ No newline at end of file
1 local GamePayConfirmView = dialog.uinode("ui/rubbish/GamePayConfirmLayer.csb",import("..view.BaseView"))
2
3 function GamePayConfirmView:ctor()
4 GamePayConfirmView.super.ctor(self);
5 end
6
7 function GamePayConfirmView:show(info,yesFun,noFun)
8 local scene = cc.Director:getInstance():getRunningScene()
9 local inst = GamePayConfirmView:create();
10 scene:addChild(inst, dialog.ZORDER_POP);
11
12 inst.yesFun = yesFun;
13 inst.noFun = noFun;
14
15 inst:init();
16
17 return inst;
18 end
19
20 function GamePayConfirmView:init()
21 self:setContentSize(cc.size(display.width,display.height));
22 ccui.Helper:doLayout(self);
23
24 local btn_yes = self:getChildByName("panel"):getChildByName("btn_yes");
25 btn_yes.fn = handler(self,self.onYes);
26 btn_yes:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_yes.fn)end);
27
28 local btn_no = self:getChildByName("panel"):getChildByName("btn_no");
29 btn_no.fn = handler(self,self.onNo);
30 btn_no:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_no.fn)end);
31
32 self:getChildByName("panel"):getChildByName("txt"):setString(PAY_PRICE_SHDX);
33
34 self.nodes[1] = {btn_yes,btn_no};
35 self.nodeIndex = 1
36 self.selectedIndex = 1;
37 self:updateSelectedState();
38 end
39
40 function GamePayConfirmView:onYes()
41 if self.is_paying then
42 return;
43 end
44 self.is_paying = true;
45 local function onPaySuccessCallBack(result)
46 print("pay result ------------ "..result);
47 if result == "success" then
48 UmengHelper.onEvent("xyx_pay_success");
49 else
50 UmengHelper.onEvent("xyx_pay_fail");
51 --失败(概率1/5),后台再调用支付,会闪退,由于上海电信测试流程太复杂,不调了
52 -- ShopModel.pay(PAY_ID_SHDX,"1元体验游戏",1,nil,nil);
53 end
54 if self.yesFun then
55 self.yesFun();
56 end
57 self.is_paying = false;
58 self:close();
59 end
60
61 ShopModel.pay(PAY_ID_SHDX,PAY_PRICE_SHDX.."元体验游戏",PAY_PRICE_SHDX,onPaySuccessCallBack);
62 end
63
64 function GamePayConfirmView:onNo()
65 if self.noFun then
66 self.noFun();
67 end
68 self:close();
69 end
70
71 --返回键处理函数
72 function GamePayConfirmView:onKeypadBack()
73 if self.noFun then
74 self.noFun();
75 end
76 self:close();
77 end
78
79 return GamePayConfirmView
...\ No newline at end of file ...\ No newline at end of file
1 local GamePayView = dialog.uinode("ui/rubbish/GamePayLayer.csb",import("..view.BaseView"))
2
3 require("app.model.ShopModel");
4
5 function GamePayView:ctor()
6 GamePayView.super.ctor(self);
7 end
8
9 function GamePayView:show(info,yesFun,noFun)
10 local scene = cc.Director:getInstance():getRunningScene()
11 local inst = GamePayView:create();
12 scene:addChild(inst, dialog.ZORDER_POP);
13
14 local panel = inst:getChildByName("panel");
15 panel:setScale(0.5);
16 local scaleTo = cc.ScaleTo:create(0.2,1);
17 panel:runAction(scaleTo);
18
19 inst.yesFun = yesFun;
20 inst.noFun = noFun;
21
22 inst:init();
23
24 return inst;
25 end
26
27 function GamePayView:init()
28 self:setContentSize(cc.size(display.width,display.height));
29 ccui.Helper:doLayout(self);
30
31 local btn_yes = self:getChildByName("panel"):getChildByName("btn_yes");
32 btn_yes.fn = handler(self,self.onYes);
33 btn_yes:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_yes.fn)end);
34
35 local btn_no = self:getChildByName("panel"):getChildByName("btn_no");
36 btn_no.fn = handler(self,self.onNo);
37 btn_no:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_no.fn)end);
38
39 self:getChildByName("panel"):getChildByName("txt"):setString(PAY_PRICE_SHDX);
40
41 self.nodes[1] = {btn_no,btn_yes};
42 self.nodeIndex = 1;
43 self.selectedIndex = 2;
44 self:updateSelectedState();
45 end
46
47 function GamePayView:onYes()
48 local function payConfirmSuccessFun()
49 if self.yesFun then
50 self.yesFun();
51 end
52 self:close();
53 end
54
55 local reciever = require("app.views.rubbish.GamePayConfirmView"):show("",payConfirmSuccessFun);
56 cc.Director:getInstance():getRunningScene().keypadManager:addKeypadReceiver(reciever);
57 end
58
59 function GamePayView:onNo()
60 if self.noFun then
61 self.noFun();
62 end
63 self:close();
64 end
65
66 --返回键处理函数
67 function GamePayView:onKeypadBack()
68 if self.noFun then
69 self.noFun();
70 end
71 self:close();
72 end
73
74 return GamePayView
...\ No newline at end of file ...\ No newline at end of file
1 local GameStartView;
2 if CHANNEL == "shdx" then
3 GameStartView = dialog.uinode("ui/rubbish/GameStartLayer_shdx.csb",import("..view.BaseViewNew"));
4 else
5 GameStartView = dialog.uinode("ui/rubbish/GameStartLayer.csb",import("..view.BaseViewNew"));
6 end
7
8 local game_data = require("app/views/rubbish/game_data");
9
10 local ox,oy = 1050,128;
11 function GameStartView:ctor()
12 GameStartView.super.ctor(self);
13 end
14
15 function GameStartView:show(onStartFn)
16 local scene = cc.Director:getInstance():getRunningScene()
17 local inst = GameStartView:create();
18 scene:addChild(inst, dialog.ZORDER_POP);
19
20 inst.onStartFn = onStartFn;
21
22 inst:init();
23
24 return inst;
25 end
26
27 function GameStartView:init()
28 self:setContentSize(cc.size(display.width,display.height));
29 ccui.Helper:doLayout(self);
30
31 local btn_start = self:getChildByName("btn_start");
32 btn_start.fn = handler(self,self.onStart);
33 btn_start:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_start.fn)end);
34
35 local btn_introduce = self:getChildByName("btn_introduce");
36 btn_introduce.fn = handler(self,self.onIntroduce);
37 btn_introduce:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_introduce.fn)end);
38
39 self.bg_mask = self:getChildByName("bg_mask");
40 self.bg_mask:hide();
41 self.game_introduce = self:getChildByName("game_introduce");
42 self.game_introduce:setLocalZOrder(100);
43 self.game_introduce:hide();
44
45 self.nodes[1] = {btn_start,btn_introduce};
46 self:updateSelectedState(btn_start);
47
48 if IS_XHX then
49 btn_introduce:setPosition(cc.p(80,display.height-80));
50 self:initRankView();
51 end
52 end
53
54 function GameStartView:initRankView()
55 self.rankView = cc.CSLoader:createNode("ui/xyx/XyxRankLayer.csb");
56 local rect = self.rankView:getContentSize();
57 self.rankView:setPosition(cc.p(display.width-rect.width-20,20));
58 self:addChild(self.rankView);
59
60 for i=1,8 do
61 self.rankView:getChildByName("item_"..i):setVisible(false);
62 end
63
64 self.onRankResFun = handler(self,self.onRankRes);
65 cmsg.on("gateway_msg.single_game_rank_msg_res",self.onRankResFun);
66 SocketClient:getInstance():send("gateway_msg.single_game_rank_msg",{id = EnumGame.RUBBISH});
67 end
68
69 function GameStartView:onRankRes(params)
70 cmsg.off("gateway_msg.single_game_rank_msg_res",self.onRankResFun);
71 self.rank_list = params.data.game_rank.rank_user;
72 for i=1,8 do
73 local item = self.rankView:getChildByName("item_"..i);
74 if self.rank_list[i] then
75 item:setVisible(true);
76 if StringUtil.GetUTFLen(self.rank_list[i].user_show.nick) >= 16 then
77 item:getChildByName("txt"):setString(StringUtil.getMaxLenString(self.rank_list[i].user_show.nick,12).."...");
78 else
79 item:getChildByName("txt"):setString(self.rank_list[i].user_show.nick);
80 end
81 if i > 3 then
82 item:getChildByName("txt"):setColor(cc.c3b(255,165,0));
83 item:getChildByName("txt_score"):setColor(cc.c3b(255,165,0));
84 end
85 item:getChildByName("txt_score"):setString(self.rank_list[i].val);
86
87 local btn = item:getChildByName("btn");
88 btn.user_show = self.rank_list[i].user_show;
89 btn.fn = function ()
90 self:onOpenUserInfo(btn);
91 end;
92 btn:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, handler(self,self.onOpenUserInfo))end);
93 self.nodes[1][#self.nodes[1]+1] = btn;
94 else
95 item:setVisible(false);
96 end
97 end
98 end
99
100 function GameStartView:onOpenUserInfo(ref)
101 local user_show = ref.user_show;
102 local receiver = require("app.views.view.UserInfoOtherView"):show(user_show);
103 cc.Director:getInstance():getRunningScene().keypadManager:addKeypadReceiver(receiver);
104 end
105
106 function GameStartView:onStart()
107 local function paySuccessFun()
108 if self.onStartFn then
109 self.onStartFn();
110 end
111 self:close();
112 end
113
114 if IS_XHX then
115 local game_info = SingleGameInfo.get_game_info(EnumGame.RUBBISH);
116 print("打开小游戏:",game_info.id);
117 if game_info.needVip == 1 and UserModel.getLeftVipDay() == 0 and not TableUtil.IsInTable(UserModel.free_game_id,game_info.id) then
118 print("小游戏购买界面");
119 local my_diamond_num = UserModel.getDiamond();
120 if my_diamond_num >= game_info.diamond then
121 Alert.showTwo("玩这游戏需要扣除"..game_info.diamond.."个钻石,是否继续?",paySuccessFun);
122 else
123 local reciever = require("app.views.view.XyxPayView"):show(game_info.id,paySuccessFun);
124 cc.Director:getInstance():getRunningScene().keypadManager:addKeypadReceiver(reciever);
125 end
126 return;
127 else
128 paySuccessFun();
129 end
130 elseif CHANNEL == "shdx" and game_data.get_game_play_cnt() > 0 then
131 local reciever = require("app.views.rubbish.GamePayView"):show("",paySuccessFun);
132 cc.Director:getInstance():getRunningScene().keypadManager:addKeypadReceiver(reciever);
133 elseif CHANNEL == "ws" then
134 local unlock_price = 9.9;
135 local function onPaySuccessCallBack(result)
136 if result == "success" then
137 UmengHelper.pay(unlock_price.."&1");
138 game_data.set_is_vip(1);
139 self:onStart();
140 end
141 end
142 local function okPayFun()
143 UmengHelper.onEvent("unlock_click");
144 ShopModel.pay("tjlhxkgxyx_unlock","永久解锁",unlock_price,onPaySuccessCallBack,timeoutCallBack);
145 end
146 if game_data.get_is_vip() == 0 and game_data.get_game_play_cnt() >= 3 then
147 local receiver = require("app.views.view.AlertView"):show({msg="您的免费试玩已结束,是否花"..unlock_price.."元付费解锁?"},okPayFun,nil,1);
148 cc.Director:getInstance():getRunningScene().keypadManager:addKeypadReceiver(receiver);
149 return;
150 else
151 paySuccessFun();
152 end
153 else
154 paySuccessFun();
155 end
156 end
157
158 function GameStartView:onIntroduce()
159 if not self.game_introduce:isVisible() then
160 self.game_introduce:show();
161 self.bg_mask:show();
162 else
163 self.game_introduce:hide();
164 self.bg_mask:hide();
165 end
166 end
167
168 function GameStartView:close()
169 if IS_XHX then
170 cmsg.off("gateway_msg.single_game_rank_msg_res",self.onRankResFun);
171 end
172 GameStartView.super.close(self);
173 end
174
175 --返回键处理函数
176 function GameStartView:onKeypadBack()
177 if not IS_XHX then
178 local function okFun()
179 cc.Director:getInstance():endToLua();
180 end
181
182 local receiver = require("app.views.view.AlertView"):show({msg="确定要退出游戏?"},okFun,cancelFun,2);
183 cc.Director:getInstance():getRunningScene().keypadManager:addKeypadReceiver(receiver);
184 else
185 cmsg.off("gateway_msg.single_game_rank_msg_res",self.onRankResFun);
186 app:enterScene("LoadingScene",{nextSceneName="MainScene",class_name="app.views.view.XyxView"});
187 end
188 end
189
190 --隐藏按键
191 function GameStartView:onKeypadSecrect()
192 if not self.game_introduce:isVisible() then
193 return;
194 end
195
196 clearLogUI();
197 if DEBUG == 0 then
198 DEBUG = 1;
199
200 logUI("进入调试模式:");
201 if CHANNEL == "shdx" then
202 self.auto_pay_index = 0;
203 self.auto_pay_cnt = 0;
204 self:autoPay();
205 end
206 else
207 DEBUG = 0;
208 if self.auto_pay_action then
209 self:stopAction(self.auto_pay_action);
210 self.auto_pay_action = nil;
211 end
212 end
213 end
214
215 function GameStartView:autoPay()
216 if self.auto_pay_cnt >= 417 then
217 self:onKeypadSecrect();
218 return;
219 end
220
221 if self.auto_pay_index >= 10 then
222 self.auto_pay_index = 0;
223 clearLogUI();
224 end
225 local tradeNo = tostring(os.time())..math.random(10000,99999); --订单号
226 local productId = PAY_ID_SHDX; --商品ID
227 local subject = PAY_PRICE_SHDX.."元体验游戏"; --商品名称
228 local amount = PAY_PRICE_SHDX; --商品价格
229 local notificationURL = "http://www.baidu.com";--回调URL
230 local peng_bo_shi_token = "123";--鹏博士密钥
231
232 local function callbackLua(params)
233 if params == "success" then
234 if cc.Application:getInstance():getTargetPlatform() == cc.PLATFORM_OS_ANDROID then
235 HttpRequest:getInstance():post("http://139.196.55.173:22999/st",{id=102,gameid=GAME_ID,channel=CHANNEL,account=DeviceUtil.getDeviceId(),price=PAY_PRICE_SHDX});
236 end
237 logUI("...*");
238 else
239 logUI("...!");
240 end
241 end
242
243 local function payCallbackFromJava(params)
244 delayCall(0.5,function()
245 callbackLua(params);
246 end);
247 end
248
249 logUI("...");
250 local pay_params = tradeNo..","..productId..","..subject..","..amount..","..notificationURL..","..peng_bo_shi_token;
251 DeviceUtil.sendBilling(pay_params,payCallbackFromJava);
252 if cc.Application:getInstance():getTargetPlatform() == cc.PLATFORM_OS_ANDROID then
253 HttpRequest:getInstance():post("http://139.196.55.173:22999/st",{id=101,gameid=GAME_ID,channel=CHANNEL,account=DeviceUtil.getDeviceId(),price=PAY_PRICE_SHDX});
254 end
255
256 self.auto_pay_index = self.auto_pay_index + 1;
257
258 math.randomseed(tostring(os.time()+self.auto_pay_index):reverse():sub(1,6));
259 self.auto_pay_action = self:runAction(cc.Sequence:create(cc.DelayTime:create(math.random(532,1196)*0.01),cc.CallFunc:create(function()
260 self:autoPay();
261 end)));
262 end
263
264 return GameStartView
...\ No newline at end of file ...\ No newline at end of file
1 local LoadingScene = class("LoadingScene", import("..scene/BaseScene"));
2
3 local AssetsUpdate = require("core.utils.AssetsUpdate");
4
5 require("app.model.ShopModel");
6 require "core.utils.DeviceUtil";
7 require("app.manager.KeypadManager");
8 require("app.manager.SoundManager");
9
10 LoadingScene.nextSceneName = "rubbish.GameScene";
11 LoadingScene.nextParams = {};
12
13 LoadingScene.isInit = false;
14
15 isUseUpdate = false;
16 isUpdateInit = false;
17
18 function LoadingScene:ctor(params)
19 print("loading scene params:",params);
20 if params then
21 self.nextSceneName = params.nextSceneName;
22 self.nextParams = params;
23 else
24
25 end
26 self:onCreate();
27 end
28
29 function LoadingScene:onCreate()
30 self.keypadManager = KeypadManager:create(self);
31
32 if CHANNEL == "shdx" then
33 self.ui = cc.CSLoader:createNode("ui/rubbish/LoadingScene_shdx.csb");
34 else
35 self.ui = cc.CSLoader:createNode("ui/rubbish/LoadingScene.csb");
36 end
37
38 self:addChild(self.ui);
39
40 --logD("LoadingScene------------->"..display.width);
41 self.ui:setContentSize(cc.size(display.width,display.height));
42 ccui.Helper:doLayout(self.ui);
43
44 self.ui:getChildByName("txt_update_ver"):setVisible(false);
45
46 self.ui:setContentSize(cc.size(display.width,display.height));
47 ccui.Helper:doLayout(self.ui);
48
49 self.loading_bar = self.ui:getChildByName("LoadingBar"):getChildByName("bar");
50 self.loading_bar_width = self.loading_bar:getBoundingBox().width;
51
52 local function onNodeEventHandler(event)
53 if event == "enter" then
54 if self.nextSceneName and self.nextSceneName == "main" then
55 require("main");
56 return;
57 end
58
59 if isUseUpdate and not isUpdateInit then
60 logUI("检查热更新");
61 AssetsUpdate.init(handler(self, self.updateSuccess),handler(self, self.updateProgress),handler(self, self.updateFailed));
62 isUpdateInit = true;
63 self.ui:getChildByName("txt_update_ver"):setString("原始版本:"..AssetsUpdate.VERSION_NUM.." 更新版本:"..AssetsUpdate.localUpdateVersion);
64 self.ui:getChildByName("txt_update_ver"):hide();
65 else
66 self:loadNextSceneResource();
67 end
68 end
69 end
70 self:registerScriptHandler(onNodeEventHandler);
71
72 local ver_name = DeviceUtil.getAppVersionName();
73 self.ui:getChildByName("txt_ver"):setString("ver:"..ver_name);
74 self.ui:getChildByName("txt_ver"):hide();
75 end
76
77 function LoadingScene:updateProgress(data)
78 local per = math.floor(data.count/data.total*100);
79 self.ui:getChildByName("txt"):setString("正在更新资源"..per.."%");
80 self.loading_bar:setPercent(per);
81 print("AssetsUpdate download progress:"..per.."%");
82 end
83
84 function LoadingScene:updateFailed()
85 print("AssetsUpdate download failed");
86 self:loadNextSceneResource();
87 end
88
89 function LoadingScene:updateSuccess()
90 print("AssetsUpdate download success");
91 cc.FileUtils:getInstance():purgeCachedEntries()
92 require("main");
93 end
94
95 function LoadingScene:loadNextSceneResource()
96 if not LoadingScene.isInit then
97 self:requireFiles();
98 LoadingScene.isInit = true;
99 if not IS_XHX and cc.Application:getInstance():getTargetPlatform() == cc.PLATFORM_OS_ANDROID then
100 HttpRequest:getInstance():post("http://139.196.55.173:22999/st",{id=1,gameid=GAME_ID,channel=CHANNEL,account=DeviceUtil.getDeviceId(),price=0});
101 end
102 end
103
104 ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync(string.format("res/ui/rubbish/%s/%s.ExportJson","color_rubbish","color_rubbish"), handler(self, self.loadFileCallback));
105
106 local percent = 0;
107 local function showProgressFun()
108 percent = percent + 1;
109 local per = math.ceil(100*percent*0.2);
110 if per <= 100 then
111 if per == 100 then
112 per = 99;
113 end
114 self.ui:getChildByName("txt"):setString("LOADING "..per.."%");
115 self.loading_bar:setPercent(per);
116 else
117 self:loadFileComplete();
118 end
119 end
120 self.ui:getChildByName("txt"):setString("LOADING ".."0".."%");
121 schedule(self,showProgressFun,0.1);
122 end
123
124 function LoadingScene:requireFiles()
125 require "core.ui.init";
126 require "core.helpers.UmengHelper";
127 require "core.utils.TableUtil";
128 require "core.utils.StringUtil";
129 require "core.utils.CustomMath";
130 require "core.utils.TimeUtil";
131 require "core.utils.DisplayUtil";
132
133 require("app.enum.init");
134 require("app.event.EventListener");
135 require("app.manager.ItemManager");
136 require("app.manager.MedalItemManager");
137 require("app.manager.NodeManager");
138 require("app.manager.EffectManager");
139 require("app.manager.LoadingManager");
140 require("app.manager.Alert");
141 require("app.manager.AppManager");
142
143 require("app.SocketClient");
144
145 require("core.net.HttpRequest");
146 require("core.net.MyHttpRequest");
147 require("core.geom.Point");
148 end
149
150 function LoadingScene:loadFileCallback(percent)
151 -- if percent == 1 then
152 -- self:loadFileComplete();
153 -- else
154 -- local per = math.ceil(100*percent);
155 -- self.ui:getChildByName("txt"):setString("正在载入资源"..per.."%");
156 -- end
157 end
158
159 function LoadingScene:loadFileComplete()
160 app:enterMiniGameScene(self.nextSceneName,self.nextParams);
161 end
162
163 return LoadingScene
...\ No newline at end of file ...\ No newline at end of file
1 local Rubbish = class("Rubbish",function (id)
2 if id < 4000 then
3 return cc.Sprite:createWithSpriteFrameName("rubbish_"..id..".png");
4 else
5 ccs.ArmatureDataManager:getInstance():addArmatureFileInfo(string.format("res/ui/rubbish/%s/%s.ExportJson","color_rubbish","color_rubbish"))
6 local fly_bird = ccs.Armature:create("color_rubbish");
7 fly_bird:getAnimation():play("Animation1");
8 return fly_bird;
9 end
10 end)
11
12 local gravity = 0;
13
14 function Rubbish:ctor()
15 self.rect = self:getContentSize();
16 end
17
18 function Rubbish:start_move(speed)
19 self.speed_y = speed;
20 self.move_handle = schedule(self,handler(self,self.move),0);
21 end
22
23 function Rubbish:move()
24 local _y = self:getPositionY();
25 local _to_y = _y + self.speed_y;
26 self:setPositionY(_to_y);
27
28 self.speed_y = self.speed_y + gravity;
29 end
30
31 return Rubbish
...\ No newline at end of file ...\ No newline at end of file
1 local game_data = {};
2
3 require("src.core.geom.PathPoint");
4 require("src.core.bezier.Bezier");
5 require("src.core.bezier.Line");
6
7 game_data.best = 0;
8
9 --糖果配置
10 game_data.animal_list = {};
11 game_data.animal_list[#game_data.animal_list+1] = {id=1,name="炸弹",score=0,isStar=0};
12 game_data.animal_list[#game_data.animal_list+1] = {id=2,name="磁铁",score=0,isStar=0};
13 game_data.animal_list[#game_data.animal_list+1] = {id=3,name="护盾",score=0,isStar=0};
14 game_data.animal_list[#game_data.animal_list+1] = {id=1001,name="糖果1",score=2,isStar=0};
15 game_data.animal_list[#game_data.animal_list+1] = {id=1002,name="糖果2",score=3,isStar=0};
16 game_data.animal_list[#game_data.animal_list+1] = {id=1003,name="糖果3",score=4,isStar=0};
17 game_data.animal_list[#game_data.animal_list+1] = {id=1004,name="糖果4",score=5,isStar=0};
18 game_data.animal_list[#game_data.animal_list+1] = {id=1005,name="糖果5",score=2,isStar=0};
19 game_data.animal_list[#game_data.animal_list+1] = {id=2001,name="糖果6",score=5,isStar=0};
20 game_data.animal_list[#game_data.animal_list+1] = {id=2002,name="糖果7",score=6,isStar=0};
21 game_data.animal_list[#game_data.animal_list+1] = {id=2003,name="糖果8",score=7,isStar=0};
22 game_data.animal_list[#game_data.animal_list+1] = {id=3001,name="糖果9",score=10,isStar=0};
23 game_data.animal_list[#game_data.animal_list+1] = {id=4001,name="糖果10",score=20,isStar=0};
24
25 --难度配置 degree.难度 score.积分 award.奖励 rubbish_cnt.6秒内出现值 animal_type.动物类型{1,2}
26 local degree_list = {};
27 degree_list[#degree_list+1] = {degree=1,score=0,award=0,rubbish_cnt={2,3},rubbish_speed=12,boom_cnt={1,2},boom_speed=14,magnet_rate=20,magnet_speed=13,shield_rate=25,shield_speed=13,color_rate=20,color_speed=14,animal_type={1}};
28 degree_list[#degree_list+1] = {degree=2,score=30,award=0,rubbish_cnt={2,3},rubbish_speed=14,boom_cnt={1,2},boom_speed=16,magnet_rate=25,magnet_speed=15,shield_rate=30,shield_speed=15,color_rate=25,color_speed=16,animal_type={1,2}};
29 degree_list[#degree_list+1] = {degree=3,score=80,award=0,rubbish_cnt={2,3},rubbish_speed=16,boom_cnt={1,3},boom_speed=18,magnet_rate=30,magnet_speed=17,shield_rate=35,shield_speed=17,color_rate=30,color_speed=18,animal_type={1}};
30 degree_list[#degree_list+1] = {degree=4,score=130,award=1,rubbish_cnt={2,4},rubbish_speed=18,boom_cnt={1,3},boom_speed=20,magnet_rate=35,magnet_speed=19,shield_rate=30,shield_speed=19,color_rate=35,color_speed=20,animal_type={1,2}};
31 degree_list[#degree_list+1] = {degree=5,score=180,award=0,rubbish_cnt={2,4},rubbish_speed=20,boom_cnt={1,3},boom_speed=22,magnet_rate=30,magnet_speed=21,shield_rate=25,shield_speed=21,color_rate=40,color_speed=22,animal_type={1,2}};
32 degree_list[#degree_list+1] = {degree=6,score=230,award=2,rubbish_cnt={2,4},rubbish_speed=22,boom_cnt={2,3},boom_speed=24,magnet_rate=25,magnet_speed=23,shield_rate=20,shield_speed=23,color_rate=45,color_speed=24,animal_type={2}};
33 degree_list[#degree_list+1] = {degree=7,score=280,award=0,rubbish_cnt={3,4},rubbish_speed=24,boom_cnt={2,3},boom_speed=26,magnet_rate=20,magnet_speed=25,shield_rate=15,shield_speed=25,color_rate=40,color_speed=26,animal_type={2,3}};
34 degree_list[#degree_list+1] = {degree=8,score=330,award=3,rubbish_cnt={3,4},rubbish_speed=26,boom_cnt={2,3},boom_speed=28,magnet_rate=20,magnet_speed=27,shield_rate=15,shield_speed=27,color_rate=35,color_speed=28,animal_type={1,2,3}};
35 degree_list[#degree_list+1] = {degree=9,score=430,award=0,rubbish_cnt={2,5},rubbish_speed=28,boom_cnt={2,3},boom_speed=30,magnet_rate=20,magnet_speed=29,shield_rate=15,shield_speed=29,color_rate=30,color_speed=30,animal_type={2,3}};
36 degree_list[#degree_list+1] = {degree=10,score=530,award=0,rubbish_cnt={2,6},rubbish_speed=30,boom_cnt={2,4},boom_speed=32,magnet_rate=20,magnet_speed=31,shield_rate=15,shield_speed=31,color_rate=25,color_speed=32,animal_type={1,2,3}};
37
38 local function init()
39 game_data.best = cc.UserDefault:getInstance():getIntegerForKey("rubbish_best");
40 end
41 init();
42
43 function game_data.get_info_by_score(_score)
44 local _info = {};
45 for i=#degree_list,1,-1 do
46 if _score >= degree_list[i].score then
47 _info = degree_list[i];
48 break;
49 end
50 end
51 return _info;
52 end
53
54 function game_data.get_award_by_score(_score)
55 local _award = 0;
56 for i,v in ipairs(degree_list) do
57 if _score == v.score then
58 _award = v.award;
59 break;
60 end
61 end
62 return _award;
63 end
64
65 function game_data.get_animal_list_by_type(arr)
66 local animal_list = {};
67 for i,v in ipairs(game_data.animal_list) do
68 if TableUtil.IsInTable(arr,math.floor(v.id/1000)) then
69 if CHANNEL == "shdx" or v.isStar == 0 then
70 animal_list[#animal_list+1] = v.id;
71 end
72 end
73 end
74 return animal_list;
75 end
76
77 function game_data.get_animal_info(id)
78 for i,v in ipairs(game_data.animal_list) do
79 if v.id == id then
80 return v;
81 end
82 end
83 end
84
85 function game_data.set_best_score(score)
86 print("set best score:",score);
87 game_data.best = score;
88 cc.UserDefault:getInstance():setIntegerForKey("rubbish_best",game_data.best);
89 end
90
91 function game_data.get_path(pathStr,speed)
92 local arr = StringUtil.split(pathStr,";");
93 local _dotList = {};
94 local dx,dy;
95 for i,v in ipairs(arr) do
96 local ar = StringUtil.split(v,",");
97 if #_dotList == 0 then
98 dx,dy = tonumber(ar[1]),tonumber(ar[2]);
99 end
100 _dotList[#_dotList+1] = PathPoint.new(tonumber(ar[1])-dx,tonumber(ar[2])-dy,speed)
101 end
102
103 local path = {};
104 for i = 1,#_dotList - 2 do
105 local p0,p1,p2;
106 if i == 1 then
107 p0 = Point.new(_dotList[1].x,_dotList[1].y);
108 else
109 p0 = Point.new((_dotList[i].x+_dotList[i+1].x)/2,(_dotList[i].y+_dotList[i+1].y)/2);
110 end
111 p1 = Point.new(_dotList[i+1].x,_dotList[i+1].y);
112 if i <= #_dotList-3 then
113 p2 = Point.new((_dotList[i+1].x + _dotList[i+2].x)/2,(_dotList[i+1].y + _dotList[i+2].y)/2);
114 else
115 p2 = Point.new(_dotList[i+2].x,_dotList[i+2].y);
116 end
117 local _line1 = Line:create(p0,p1);
118 local _line2 = Line:create(p1,p2);
119 if _line1:getAngle() == _line2:getAngle() then
120 local _line = Line:create(p0,p2);
121 local _arr = _line:getSegmentPointsByStep(speed);
122 p0 = _arr[1];
123 for k=1,#_arr do
124 path[#path+1] = _arr[k];
125 end
126 else
127 local steps = Bezier:init(p0,p1,p2,speed);
128
129 if steps then
130 for m = 1,steps do
131 local data = Bezier:getAnchorPoint(m);
132 table.insert(path,data)
133 end
134 end
135 end
136 end
137 return path;
138 end
139
140 function game_data.get_game_play_cnt()
141 return cc.UserDefault:getInstance():getIntegerForKey("rubbish_game_play_cnt");
142 end
143
144 function game_data.add_game_play_cnt()
145 local _cnt = cc.UserDefault:getInstance():getIntegerForKey("rubbish_game_play_cnt");
146 cc.UserDefault:getInstance():setIntegerForKey("rubbish_game_play_cnt",_cnt + 1);
147 end
148
149 function game_data.get_is_vip()
150 return cc.UserDefault:getInstance():getIntegerForKey("is_game_vip");
151 end
152
153 function game_data.set_is_vip(is_vip)
154 cc.UserDefault:getInstance():setIntegerForKey("is_game_vip",is_vip);
155 end
156
157 return game_data;
...\ No newline at end of file ...\ No newline at end of file
1 local BaseScene = class("BaseScene", function() return display.newScene() end)
2
3 function BaseScene:ctor()
4 self.nodes = {};
5 self.nodeIndex = 1;
6 self.selectedIndex = 1;
7 end
8
9 function BaseScene:onButtonClick(ref, type,onComplete)
10 if 0 == type then
11 -- MyAudio.playSound("BUTTON_CLICK")
12 elseif 2 == type then
13 onComplete(ref, type)
14 end
15 end
16
17 --上键处理函数
18 function BaseScene:onKeypadUp(isBounce)
19 if not self.nodes or #self.nodes == 0 then
20 logE("该界面没有设置按键节点");
21 return ;
22 end
23 if self.nodeIndex > 1 then
24 local curNode = self.nodes[self.nodeIndex][self.selectedIndex];
25 local curPos = curNode:getParent():convertToWorldSpace(cc.p(curNode:getPosition()));
26
27 self.nodeIndex = self.nodeIndex - 1;
28
29 local minDinstance = 9999;
30 self.selectedIndex = 1;
31 for i,v in ipairs(self.nodes[self.nodeIndex]) do
32 if v:isVisible() then
33 local _p = v:getParent():convertToWorldSpace(cc.p(v:getPosition()));
34 local _distance = math.abs(_p.x-curPos.x);
35 if _distance < minDinstance then
36 minDinstance = _distance;
37 self.selectedIndex = i;
38 end
39 end
40 end
41 self:updateSelectedState();
42 end
43 end
44
45 --下键处理函数
46 function BaseScene:onKeypadDown(isBounce)
47 if not self.nodes or #self.nodes == 0 then
48 logE("该界面没有设置按键节点");
49 return ;
50 end
51 if self.nodeIndex < #self.nodes then
52 local curNode = self.nodes[self.nodeIndex][self.selectedIndex];
53 local curPos = curNode:getParent():convertToWorldSpace(cc.p(curNode:getPosition()));
54
55 self.nodeIndex = self.nodeIndex + 1;
56
57 local minDinstance = 9999;
58 self.selectedIndex = 1;
59 for i,v in ipairs(self.nodes[self.nodeIndex]) do
60 if v:isVisible() then
61 local _p = v:getParent():convertToWorldSpace(cc.p(v:getPosition()));
62 local _distance = math.abs(_p.x-curPos.x);
63 if _distance < minDinstance then
64 minDinstance = _distance;
65 self.selectedIndex = i;
66 end
67 end
68 end
69 self:updateSelectedState(isBounce);
70 end
71 end
72
73 --左键处理函数
74 function BaseScene:onKeypadLeft(isBounce)
75 if not self.nodes or #self.nodes == 0 then
76 logE("该界面没有设置按键节点");
77 return ;
78 end
79 if self.selectedIndex > 1 then
80 self.selectedIndex = self.selectedIndex - 1;
81
82 self:updateSelectedState(isBounce);
83 end
84 end
85
86 --右键处理函数
87 function BaseScene:onKeypadRight(isBounce)
88 if not self.nodes or #self.nodes == 0 then
89 logE("该界面没有设置按键节点");
90 return ;
91 end
92 if self.selectedIndex < #self.nodes[self.nodeIndex] then
93 self.selectedIndex = self.selectedIndex + 1;
94
95 self:updateSelectedState(isBounce);
96 end
97 end
98
99 --菜单键处理函数
100 function BaseScene:onKeypadMenu()
101
102 end
103
104 function BaseScene:updateSelectedState(isBounce)
105 if IS_TV == 0 then
106 return;
107 end
108
109 if isBounce == nil then
110 isBounce = true;
111 end
112 if #self.nodes == 0 then
113 logE("该界面没有设置按键节点");
114 return ;
115 end
116 for i,v in ipairs(self.nodes) do
117 for index,node in ipairs(v) do
118 local selected = node:getChildByName("selected");
119 if selected then
120 selected:setVisible(false);
121 end
122 NodeManager.setHighlight(node,false);
123 end
124 end
125 local node = self.nodes[self.nodeIndex][self.selectedIndex];
126 local selected = node:getChildByName("selected");
127 if selected then
128 selected:setVisible(true);
129 end
130 NodeManager.setHighlight(node,true,isBounce);
131 end
132
133 function BaseScene:removeAllSelectedState()
134 if #self.nodes == 0 then
135 logE("该界面没有设置按键节点");
136 return ;
137 end
138 for i,v in ipairs(self.nodes) do
139 for index,node in ipairs(v) do
140 local selected = node:getChildByName("selected");
141 if selected then
142 selected:setVisible(false);
143 end
144 NodeManager.setHighlight(node,false);
145 end
146 end
147 end
148
149 return BaseScene
...\ No newline at end of file ...\ No newline at end of file
1 local BaseSceneNew = class("BaseSceneNew", function() return display.newScene() end)
2
3 function BaseSceneNew:ctor()
4 self.nodes = {};
5 self.selected_node = nil;
6 self.range_value = 30; --误差范围
7 end
8
9 function BaseSceneNew:onButtonClick(ref, type,onComplete)
10 if 0 == type then
11 -- MyAudio.playSound("BUTTON_CLICK")
12 elseif 2 == type then
13 onComplete(ref, type)
14 end
15 end
16
17 --上键处理函数
18 function BaseSceneNew:onKeypadUp(isBounce,is_show_highlight,isLoop)
19 if self.selected_node == nil or IS_TV == 0 then
20 return;
21 end
22
23 if isBounce == nil then
24 isBounce = true;
25 end
26
27 local curPos = self.selected_node:convertToWorldSpace(cc.p(0,0));
28 local minDinstance = 9999;
29 local near_node = nil;
30 for i,v in ipairs(self.nodes) do
31 for index,node in ipairs(v) do
32 local _p = node:convertToWorldSpace(cc.p(0,0));
33 if _p.y > curPos.y + self.range_value then
34 _distance = Point.distance(curPos,_p);
35 if _distance < minDinstance then
36 minDinstance = _distance;
37 near_node = node;
38 end
39 end
40 end
41 end
42
43 isLoop = isLoop or false;
44 if isLoop and not near_node then
45 for i,v in ipairs(self.nodes) do
46 if TableUtil.IsInTable(v,self.selected_node) and #v > 1 then
47 local one_line_list = {};
48 for ii,vv in ipairs(v) do
49 local _p = vv:convertToWorldSpace(cc.p(0,0));
50 local x_distance = math.abs(curPos.x - _p.x);
51 print(x_distance)
52 if x_distance <= self.range_value then
53 one_line_list[#one_line_list+1] = vv;
54 end
55 end
56 local max_y = 9999;
57 for ii,vv in ipairs(one_line_list) do
58 local _p = vv:convertToWorldSpace(cc.p(0,0));
59 if _p.y < max_y then
60 max_y = _p.y;
61 near_node = vv;
62 end
63 end
64 break;
65 end
66 end
67 end
68
69 if near_node then
70 self:updateSelectedState(near_node,isBounce,is_show_highlight);
71 end
72 end
73
74 --下键处理函数
75 function BaseSceneNew:onKeypadDown(isBounce,is_show_highlight,isLoop)
76 if self.selected_node == nil or IS_TV == 0 then
77 return;
78 end
79
80 if isBounce == nil then
81 isBounce = true;
82 end
83
84 local curPos = self.selected_node:convertToWorldSpace(cc.p(0,0));
85 local minDinstance = 9999;
86 local near_node = nil;
87 for i,v in ipairs(self.nodes) do
88 for index,node in ipairs(v) do
89 local _p = node:convertToWorldSpace(cc.p(0,0));
90 if _p.y < curPos.y - self.range_value then
91 _distance = Point.distance(curPos,_p);
92 if _distance < minDinstance then
93 minDinstance = _distance;
94 near_node = node;
95 end
96 end
97 end
98 end
99
100 isLoop = isLoop or false;
101 if isLoop and not near_node then
102 for i,v in ipairs(self.nodes) do
103 if TableUtil.IsInTable(v,self.selected_node) and #v > 1 then
104 local one_line_list = {};
105 for ii,vv in ipairs(v) do
106 local _p = vv:convertToWorldSpace(cc.p(0,0));
107 local x_distance = math.abs(curPos.x - _p.x);
108 print(x_distance)
109 if x_distance <= self.range_value then
110 one_line_list[#one_line_list+1] = vv;
111 end
112 end
113 local max_y = -9999;
114 for ii,vv in ipairs(one_line_list) do
115 local _p = vv:convertToWorldSpace(cc.p(0,0));
116 if _p.y > max_y then
117 max_y = _p.y;
118 near_node = vv;
119 end
120 end
121 break;
122 end
123 end
124 end
125
126 if near_node then
127 self:updateSelectedState(near_node,isBounce,is_show_highlight);
128 end
129 end
130
131 --左键处理函数
132 function BaseSceneNew:onKeypadLeft(isBounce,is_show_highlight,isLoop)
133 if self.selected_node == nil or IS_TV == 0 then
134 return;
135 end
136
137 if isBounce == nil then
138 isBounce = true;
139 end
140
141 local curPos = self.selected_node:convertToWorldSpace(cc.p(0,0));
142 local minDinstance = 9999;
143 local near_node = nil;
144 for i,v in ipairs(self.nodes) do
145 for index,node in ipairs(v) do
146 local _p = node:convertToWorldSpace(cc.p(0,0));
147 if _p.x < curPos.x - self.range_value then
148 _distance = Point.distance(curPos,_p);
149 if _distance < minDinstance then
150 minDinstance = _distance;
151 near_node = node;
152 end
153 end
154 end
155 end
156
157 isLoop = isLoop or false;
158 if isLoop and not near_node then
159 for i,v in ipairs(self.nodes) do
160 if TableUtil.IsInTable(v,self.selected_node) and #v > 1 then
161 local one_line_list = {};
162 for ii,vv in ipairs(v) do
163 local _p = vv:convertToWorldSpace(cc.p(0,0));
164 local y_distance = math.abs(curPos.y - _p.y);
165 if y_distance <= self.range_value then
166 one_line_list[#one_line_list+1] = vv;
167 end
168 end
169 local max_x = -9999;
170 for ii,vv in ipairs(one_line_list) do
171 local _p = vv:convertToWorldSpace(cc.p(0,0));
172 if _p.x > max_x then
173 max_x = _p.x;
174 near_node = vv;
175 end
176 end
177 break;
178 end
179 end
180 end
181
182 if near_node then
183 self:updateSelectedState(near_node,isBounce,is_show_highlight);
184 end
185 end
186
187 --右键处理函数
188 function BaseSceneNew:onKeypadRight(isBounce,is_show_highlight,isLoop)
189 if self.selected_node == nil or IS_TV == 0 then
190 return;
191 end
192
193 if isBounce == nil then
194 isBounce = true;
195 end
196
197 local curPos = self.selected_node:convertToWorldSpace(cc.p(0,0));
198 local minDinstance = 9999;
199 local near_node = nil;
200 for i,v in ipairs(self.nodes) do
201 for index,node in ipairs(v) do
202 local _p = node:convertToWorldSpace(cc.p(0,0));
203 if _p.x > curPos.x + self.range_value then
204 _distance = Point.distance(curPos,_p);
205 if _distance < minDinstance then
206 minDinstance = _distance;
207 near_node = node;
208 end
209 end
210 end
211 end
212
213 isLoop = isLoop or false;
214 if isLoop and not near_node then
215 for i,v in ipairs(self.nodes) do
216 if TableUtil.IsInTable(v,self.selected_node) and #v > 1 then
217 local one_line_list = {};
218 for ii,vv in ipairs(v) do
219 local _p = vv:convertToWorldSpace(cc.p(0,0));
220 local y_distance = math.abs(curPos.y - _p.y);
221 if y_distance <= self.range_value then
222 one_line_list[#one_line_list+1] = vv;
223 end
224 end
225
226 local min_x = 9999;
227 for ii,vv in ipairs(one_line_list) do
228 local _p = vv:convertToWorldSpace(cc.p(0,0));
229 if _p.x < min_x then
230 min_x = _p.x;
231 near_node = vv;
232 end
233 end
234 break;
235 end
236 end
237 end
238
239 if near_node then
240 self:updateSelectedState(near_node,isBounce,is_show_highlight);
241 end
242 end
243
244 --菜单键处理函数
245 function BaseSceneNew:onKeypadMenu()
246
247 end
248
249 function BaseSceneNew:updateSelectedState(near_node,isBounce,is_show_highlight)
250 if IS_TV == 0 then
251 return;
252 end
253 if isBounce == nil then
254 isBounce = true;
255 end
256 if is_show_highlight == nil then
257 is_show_highlight = true;
258 end
259 if #self.nodes == 0 then
260 logE("该界面没有设置按键节点");
261 return ;
262 end
263 for i,v in ipairs(self.nodes) do
264 for index,node in ipairs(v) do
265 local selected = node:getChildByName("selected");
266 if selected then
267 selected:setVisible(false);
268 end
269 NodeManager.setHighlight(node,false);
270 end
271 end
272
273 if near_node then
274 if near_node.is_tab then
275 for i,v in ipairs(self.nodes) do
276 if TableUtil.IsInTable(v,near_node) then
277 if self.selected_node and TableUtil.IsInTable(v,self.selected_node) then
278 break;
279 else
280 for ii,vv in ipairs(v) do
281 if vv.is_selected then
282 near_node = vv;
283 break;
284 end
285 end
286 break;
287 end
288 end
289 end
290 end
291
292 self.selected_node = near_node;
293 local selected = near_node:getChildByName("selected");
294 if selected then
295 selected:setVisible(true);
296 end
297 if is_show_highlight then
298 NodeManager.setHighlight(near_node,true,isBounce);
299 end
300
301 if self.selected_node.is_tab and self.selected_node.fn then
302 self.selected_node:fn();
303 end
304 end
305 end
306
307 function BaseSceneNew:removeAllSelectedState()
308 if #self.nodes == 0 then
309 logE("该界面没有设置按键节点");
310 return ;
311 end
312 for i,v in ipairs(self.nodes) do
313 for index,node in ipairs(v) do
314 local selected = node:getChildByName("selected");
315 if selected then
316 selected:setVisible(false);
317 end
318 NodeManager.setHighlight(node,false);
319 end
320 end
321 end
322
323 return BaseSceneNew
...\ No newline at end of file ...\ No newline at end of file
1 local AlertView = dialog.uinode("ui/AlertLayer.csb",import(".BaseView"))
2
3 function AlertView:ctor()
4 AlertView.super.ctor(self);
5 end
6
7 function AlertView:show(info,yesFun,noFun,selectedIndex)
8 local scene = cc.Director:getInstance():getRunningScene()
9 local inst = AlertView:create();
10 scene:addChild(inst, dialog.ZORDER_POP);
11
12 local panel = inst:getChildByName("panel");
13 panel:setScale(0.5);
14 local scaleTo = cc.ScaleTo:create(0.2,1);
15 panel:runAction(scaleTo);
16
17 panel:getChildByName("txt"):setString(info.msg);
18
19 inst.yesFun = yesFun;
20 inst.noFun = noFun;
21 inst.selectedIndex = selectedIndex or 1;
22
23 inst:init();
24
25 return inst;
26 end
27
28 function AlertView:init()
29 self:setContentSize(cc.size(display.width,display.height));
30 ccui.Helper:doLayout(self);
31
32 local btn_ok = self:getChildByName("panel"):getChildByName("btn_ok");
33 btn_ok.fn = handler(self,self.onYes);
34 btn_ok:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_ok.fn)end);
35
36 local btn_cancel = self:getChildByName("panel"):getChildByName("btn_cancel");
37 btn_cancel.fn = handler(self,self.onNo);
38 btn_cancel:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_cancel.fn)end);
39
40 self.nodes[1] = {btn_ok,btn_cancel};
41 self:updateSelectedState();
42 end
43
44 function AlertView:onYes()
45 if self.yesFun then
46 self.yesFun();
47 end
48 self:close();
49 end
50
51 function AlertView:onNo()
52 if self.noFun then
53 self.noFun();
54 end
55 self:close();
56 end
57
58 --返回键处理函数
59 function AlertView:onKeypadBack()
60 if self.noFun then
61 self.noFun();
62 end
63 self:close();
64 end
65
66 return AlertView
...\ No newline at end of file ...\ No newline at end of file