Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
db-game-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
崔立强
db-game-template
Commits
921594a7
Commit
921594a7
authored
Jul 05, 2019
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
e7c21374
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
166 additions
and
26 deletions
+166
-26
publish.js
egret/publish.js
+2
-2
1.js
egret/src/1.js
+0
-0
Main.ts
egret/src/Main.ts
+4
-1
getMusicUrl.ts
egret/src/getMusicUrl.ts
+124
-0
PlayScene.ts
egret/src/playScene/PlayScene.ts
+10
-4
soundCtrl.ts
egret/src/soundCtrl.ts
+26
-19
No files found.
egret/publish.js
View file @
921594a7
...
@@ -24,8 +24,8 @@ class TuiaAutoUpload {
...
@@ -24,8 +24,8 @@ class TuiaAutoUpload {
var
_this
=
this
;
var
_this
=
this
;
this
.
client
=
new
OSS
({
this
.
client
=
new
OSS
({
region
:
'oss-cn-hangzhou'
,
region
:
'oss-cn-hangzhou'
,
accessKeyId
:
'LTAI
dGi1IOap7fkF
'
,
accessKeyId
:
'LTAI
qO2wblIxQvwc
'
,
accessKeySecret
:
'
SKrOOp6EVtDGEV47yn0t2h97gyNioQ
'
,
accessKeySecret
:
'
4brsaSRbRpjxw3oDIxJi6bNMcndIR6
'
,
bucket
:
_this
.
type
===
'prod'
?
'duiba'
:
'daily-duiba'
bucket
:
_this
.
type
===
'prod'
?
'duiba'
:
'daily-duiba'
});
});
this
.
bar
=
new
ProgressBar
(
chalk
.
yellow
(
` 文件上传中 [:bar] :current/
${
this
.
files
().
length
}
:percent :elapseds`
),
{
this
.
bar
=
new
ProgressBar
(
chalk
.
yellow
(
` 文件上传中 [:bar] :current/
${
this
.
files
().
length
}
:percent :elapseds`
),
{
...
...
egret/src/1.js
0 → 100644
View file @
921594a7
egret/src/Main.ts
View file @
921594a7
import
MainBase
from
"../libs/new_wx/MainBase"
;
import
MainBase
from
"../libs/new_wx/MainBase"
;
import
getMusicUrl
from
"./getMusicUrl"
;
class
Main
extends
MainBase
{
class
Main
extends
MainBase
{
}
}
...
@@ -15,4 +16,6 @@ egret.runEgret({
...
@@ -15,4 +16,6 @@ egret.runEgret({
context
.
backingStorePixelRatio
||
1
;
context
.
backingStorePixelRatio
||
1
;
return
(
window
.
devicePixelRatio
||
1
)
/
backingStore
;
return
(
window
.
devicePixelRatio
||
1
)
/
backingStore
;
}
}
});
});
\ No newline at end of file
getMusicUrl
();
\ No newline at end of file
egret/src/getMusicUrl.ts
0 → 100644
View file @
921594a7
const
getToken
=
()
=>
{
return
new
Promise
((
r
)
=>
{
const
oauth_consumer_key
=
'DBAndroidClient'
;
const
clientid
=
'AndroidClient'
;
const
clientsecret
=
'123456'
;
const
oauth_consumer_secret
=
'12e390c3d9c1469c7ad9799cdc471e82'
;
const
sign
=
window
[
'duiba_md5'
](
oauth_consumer_key
+
clientid
+
clientsecret
+
oauth_consumer_secret
).
toUpperCase
();
const
sendData
=
{
oauth_consumer_key
:
oauth_consumer_key
,
oauth_consumer_sig
:
sign
,
clientid
:
clientid
,
reqEncryptType
:
"-1"
,
clientsecret
:
clientsecret
};
window
[
'$'
].
ajax
({
url
:
"https://csapi.tingmall.com/ContentServiceWS/OAuth/getAccessTokenSig"
,
type
:
'get'
,
async
:
true
,
//异步请求
cache
:
false
,
contentType
:
"application/x-www-form-urlencoded"
,
data
:
sendData
,
//使用变量sendData
//执行成功的回调函数
success
:
(
data
)
=>
{
r
(
data
.
response
.
docs
.
access_token
);
},
//执行失败或错误的回调函数
error
:
(
data
)
=>
{
console
.
log
(
"认证失败"
);
}
});
})
}
const
getCategoryItem
=
(
oauth_token
,
categoryid
)
=>
{
return
new
Promise
((
r
)
=>
{
const
sendData
=
{
categoryid
:
categoryid
};
window
[
'$'
].
ajax
({
url
:
"https://csapi.tingmall.com/ContentServiceWS/CategoryExInfo/getCategoryItem"
,
type
:
'get'
,
async
:
true
,
//异步请求
cache
:
false
,
contentType
:
"application/x-www-form-urlencoded"
,
data
:
sendData
,
//使用变量sendData
//执行成功的回调函数
success
:
(
data
)
=>
{
r
(
data
);
},
//执行失败或错误的回调函数
error
:
(
data
)
=>
{
console
.
log
(
"认证失败"
);
},
beforeSend
:
(
xhr
)
=>
{
xhr
.
setRequestHeader
(
"oauth_token"
,
oauth_token
);
}
});
});
}
const
requestMusicUrl
=
(
oauth_token
,
itemid
,
songlistid
)
=>
{
const
date
=
new
Date
();
const
y
=
date
.
getFullYear
();
const
m
=
(
date
.
getMonth
()
+
1
)
>=
10
?
(
date
.
getMonth
()
+
1
)
:
'0'
+
(
date
.
getMonth
()
+
1
);
const
d
=
date
.
getDate
()
>=
10
?
date
.
getDate
()
:
'0'
+
date
.
getDate
();
const
h
=
date
.
getHours
()
>=
10
?
date
.
getHours
()
:
'0'
+
date
.
getHours
();
const
min
=
date
.
getMinutes
()
>=
10
?
date
.
getMinutes
()
:
'0'
+
date
.
getMinutes
();
const
ms
=
date
.
getSeconds
()
>=
10
?
date
.
getSeconds
()
:
'0'
+
date
.
getSeconds
();
const
startdate
=
`
${
y
}
-
${
m
}
-
${
d
}
T
${
h
}
:
${
min
}
:
${
ms
}
Z`
;
const
enddate
=
`
${
y
+
1
}
-
${
m
}
-
${
d
}
T00:00:00Z`
;
console
.
log
(
startdate
,
enddate
);
return
new
Promise
((
r
)
=>
{
const
sendData
=
{
apimode
:
"2"
,
uid
:
CFG
.
uid
,
eventmode
:
"1Y"
,
itemid
:
itemid
,
startdate
:
startdate
,
enddate
:
enddate
,
songlistid
:
songlistid
};
window
[
'$'
].
ajax
({
url
:
"https://csapi.tingmall.com/ContentServiceWS/H5EventInfo/requestMusicUrl"
,
type
:
'get'
,
async
:
true
,
//异步请求
cache
:
false
,
contentType
:
"application/x-www-form-urlencoded"
,
data
:
sendData
,
//使用变量sendData
//执行成功的回调函数
success
:
(
data
)
=>
{
r
(
data
);
},
//执行失败或错误的回调函数
error
:
(
data
)
=>
{
console
.
log
(
"认证失败"
);
},
beforeSend
:
(
xhr
)
=>
{
xhr
.
setRequestHeader
(
"oauth_token"
,
oauth_token
);
}
});
});
}
export
default
()
=>
{
return
new
Promise
(
async
(
r
)
=>
{
// const oauth_token = await getToken();
// const categoryData: any = await getCategoryItem(oauth_token, window['categoryid']);
// const itemid = categoryData.response.docs.stationItems[0].itemID;
// const categoryid = categoryData.response.docs.categoryID;
// const musicData:any = await requestMusicUrl(oauth_token, itemid, categoryid);
const
ele
=
document
.
createElement
(
'audio'
);
ele
.
setAttribute
(
'autoplay'
,
''
);
ele
.
setAttribute
(
'loop'
,
''
);
ele
.
setAttribute
(
'preload'
,
''
);
ele
.
setAttribute
(
'id'
,
'bgmusic'
);
ele
.
setAttribute
(
'src'
,
'http://ks.tingmall.com/content/13/972/13972528-MP3-128K-FTD.mp3?wsSecret=c5e3a5a519f9f5b3c484100df9168c72&wsTime=5eff5602&transDeliveryCode=DB@153237649@1562229050@S@'
);
// ele.setAttribute('src',musicData.response.docs.playURL);
// window['musciURL'] = musicData.response.docs.playURL;
document
.
body
.
append
(
ele
);
})
}
\ No newline at end of file
egret/src/playScene/PlayScene.ts
View file @
921594a7
...
@@ -7,7 +7,7 @@ import { ModuleTypes } from "../../libs/new_wx/types/sceneTypes";
...
@@ -7,7 +7,7 @@ import { ModuleTypes } from "../../libs/new_wx/types/sceneTypes";
import
{
DataManager
}
from
"../../libs/tw/manager/DataManager"
;
import
{
DataManager
}
from
"../../libs/tw/manager/DataManager"
;
import
{
NetManager
}
from
"../../libs/tw/manager/NetManager"
;
import
{
NetManager
}
from
"../../libs/tw/manager/NetManager"
;
import
Effect
from
"../Effect"
;
import
Effect
from
"../Effect"
;
import
{
play
Bg
,
play
Sound
,
SoundType
,
toggleSound
}
from
"../soundCtrl"
;
import
{
playSound
,
SoundType
,
toggleSound
}
from
"../soundCtrl"
;
import
{
Tween
}
from
"../tween/Tween"
;
import
{
Tween
}
from
"../tween/Tween"
;
import
{
getBlocks
,
resetCounter
}
from
"./blockGen"
;
import
{
getBlocks
,
resetCounter
}
from
"./blockGen"
;
import
{
createBallItem
}
from
"./factory/createBall"
;
import
{
createBallItem
}
from
"./factory/createBall"
;
...
@@ -83,7 +83,13 @@ export default class PlayScene extends Scene {
...
@@ -83,7 +83,13 @@ export default class PlayScene extends Scene {
async
start
(
data
?)
{
async
start
(
data
?)
{
super
.
start
();
super
.
start
();
playBg
();
try
{
document
.
getElementById
(
'bgmusic'
)[
'play'
]();
}
catch
(
error
)
{
}
this
[
'musicOn'
].
visible
=
true
;
this
[
'musicOn'
].
visible
=
true
;
this
[
'musicOff'
].
visible
=
false
;
this
[
'musicOff'
].
visible
=
false
;
this
.
startGame
();
this
.
startGame
();
...
@@ -459,8 +465,8 @@ export default class PlayScene extends Scene {
...
@@ -459,8 +465,8 @@ export default class PlayScene extends Scene {
let
failed
=
false
;
let
failed
=
false
;
blocks
.
forEach
(
block
=>
{
blocks
.
forEach
(
block
=>
{
console
.
log
(
'ladderNums'
,
block
.
ladderNums
)
console
.
log
(
'ladderNums'
,
block
.
ladderNums
)
if
(
block
.
ladderNums
>=
1
)
{
//
if (block.ladderNums >= 1) {
//
if (block.ladderNums >= 9) {
if
(
block
.
ladderNums
>=
9
)
{
failed
=
true
;
failed
=
true
;
}
}
});
});
...
...
egret/src/soundCtrl.ts
View file @
921594a7
let
soundOn
=
true
;
let
soundOn
=
true
;
let
bgChannel
:
egret
.
SoundChannel
;
//
let bgChannel: egret.SoundChannel;
let
loading
=
false
;
//
let loading = false;
export
const
getSoundOn
=
()
=>
{
export
const
getSoundOn
=
()
=>
{
return
soundOn
return
soundOn
}
}
export
const
toggleSound
=
()
=>
{
export
const
toggleSound
=
()
=>
{
soundOn
=
!
soundOn
;
soundOn
=
!
soundOn
;
if
(
bgChannel
)
{
if
(
soundOn
)
{
if
(
!
soundOn
)
{
document
.
getElementById
(
'bgmusic'
)[
'play'
]();
bgChannel
.
stop
();
}
else
{
bgChannel
=
null
;
document
.
getElementById
(
'bgmusic'
)[
'pause'
]();
}
}
else
{
if
(
soundOn
)
{
playBg
();
}
}
}
// if (bgChannel) {
// if (!soundOn) {
// bgChannel.stop();
// bgChannel = null;
// }
// } else {
// if (soundOn) {
// playBg();
// }
// }
}
}
export
const
playBg
=
async
()
=>
{
// export const playBg = async () => {
if
(
bgChannel
)
return
;
// if (bgChannel) return;
if
(
loading
)
return
;
// if (loading) return;
loading
=
true
;
// loading = true;
const
bg
=
await
RES
.
getResAsync
(
'bg_mp3'
);
// RES.getResByUrl(window['musciURL'], (bg) => {
bgChannel
=
bg
.
play
();
// bgChannel = bg.play();
loading
=
false
;
// loading = false;
}
// }, this, RES.ResourceItem.TYPE_SOUND);
// }
export
enum
SoundType
{
export
enum
SoundType
{
click
=
'click'
,
click
=
'click'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment