Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
ssy003
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
template admin
ssy003
Commits
1a210fbe
Commit
1a210fbe
authored
Jul 13, 2020
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 开始点击骰子报错
parent
a25f89b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
286 additions
and
280 deletions
+286
-280
play.component.ts
src/app/play/play.component.ts
+286
-280
No files found.
src/app/play/play.component.ts
View file @
1a210fbe
...
@@ -66,6 +66,7 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -66,6 +66,7 @@ export class PlayComponent implements OnInit, OnDestroy {
canTouch
=
true
;
canTouch
=
true
;
curPic
;
curPic
;
private
isStart
:
boolean
;
@
HostListener
(
'
window:resize
'
,
[
'
$event
'
])
@
HostListener
(
'
window:resize
'
,
[
'
$event
'
])
onResize
(
event
)
{
onResize
(
event
)
{
...
@@ -98,7 +99,7 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -98,7 +99,7 @@ export class PlayComponent implements OnInit, OnDestroy {
console
.
log
(
"
canvasdefout+
"
+
this
.
canvas
);
console
.
log
(
"
canvasdefout+
"
+
this
.
canvas
);
this
.
initAudio
();
this
.
initAudio
();
this
.
initImg
();
this
.
initImg
();
},
this
.
saveKey
);
},
this
.
saveKey
);
...
@@ -127,7 +128,7 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -127,7 +128,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this
.
initCtx
();
this
.
initCtx
();
this
.
initData
();
this
.
initData
();
this
.
initView
();
this
.
initView
();
}
}
...
@@ -436,37 +437,37 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -436,37 +437,37 @@ export class PlayComponent implements OnInit, OnDestroy {
//将图片一一传到卡片上
//将图片一一传到卡片上
const
picArr
=
this
.
data
.
contentObj
.
picArr
;
const
picArr
=
this
.
data
.
contentObj
.
picArr
;
if
(
!
picArr
||
picArr
.
length
==
0
)
{
if
(
!
picArr
||
picArr
.
length
==
0
)
{
const
picArr
=
[];
const
picArr
=
[];
picArr
.
push
({
picArr
.
push
({
pic_url
:
''
,
audio_url
:
"
assets/play/music/card.mp3
"
,
title
:
"
1
"
pic_url
:
''
,
audio_url
:
"
assets/play/music/card.mp3
"
,
title
:
"
1
"
});
});
picArr
.
push
({
picArr
.
push
({
pic_url
:
''
,
audio_url
:
"
assets/play/music/card.mp3
"
,
title
:
"
2
"
pic_url
:
''
,
audio_url
:
"
assets/play/music/card.mp3
"
,
title
:
"
2
"
});
});
picArr
.
push
({
picArr
.
push
({
pic_url
:
''
,
audio_url
:
"
assets/play/music/card.mp3
"
,
title
:
"
3
"
pic_url
:
''
,
audio_url
:
"
assets/play/music/card.mp3
"
,
title
:
"
3
"
});
});
picArr
.
push
({
picArr
.
push
({
pic_url
:
''
,
audio_url
:
"
assets/play/music/card.mp3
"
,
title
:
"
4
"
pic_url
:
''
,
audio_url
:
"
assets/play/music/card.mp3
"
,
title
:
"
4
"
});
});
picArr
.
push
({
picArr
.
push
({
pic_url
:
''
,
audio_url
:
"
assets/play/music/card.mp3
"
,
title
:
"
5
"
pic_url
:
''
,
audio_url
:
"
assets/play/music/card.mp3
"
,
title
:
"
5
"
});
});
picArr
.
push
({
picArr
.
push
({
pic_url
:
''
,
audio_url
:
"
assets/play/music/card.mp3
"
,
title
:
"
6
"
pic_url
:
''
,
audio_url
:
"
assets/play/music/card.mp3
"
,
title
:
"
6
"
});
});
this
.
data
.
sideB
=
1
;
this
.
data
.
sideB
=
1
;
this
.
data
.
contentObj
.
picArr
=
picArr
;
this
.
data
.
contentObj
.
picArr
=
picArr
;
}
}
...
@@ -484,7 +485,7 @@ initAudio() {
...
@@ -484,7 +485,7 @@ initAudio() {
const
addUrlToAudioObj
=
(
audioUrl
)
=>
{
const
addUrlToAudioObj
=
(
audioUrl
)
=>
{
if
(
audioUrl
)
{
if
(
audioUrl
)
{
// console.log('audioUrl:', audioUrl);
// console.log('audioUrl:', audioUrl);
const
audio
=
new
Audio
();
const
audio
=
new
Audio
();
audio
.
src
=
audioUrl
;
audio
.
src
=
audioUrl
;
...
@@ -528,11 +529,11 @@ initAudio() {
...
@@ -528,11 +529,11 @@ initAudio() {
// addOneAudio('sm-back', this.rawAudios.get('sm-back'), 1);
// addOneAudio('sm-back', this.rawAudios.get('sm-back'), 1);
// addOneAudio('sm-display', this.rawAudios.get('sm-display'), 1);
// addOneAudio('sm-display', this.rawAudios.get('sm-display'), 1);
//addOneAudio('sm-wrong', this.rawAudios.get('sm-wrong'), 1);
//addOneAudio('sm-wrong', this.rawAudios.get('sm-wrong'), 1);
// addOneAudio('sm-win', this.rawAudios.get('sm-win'), 1);
// addOneAudio('sm-win', this.rawAudios.get('sm-win'), 1);
// addOneAudio('sm-in', this.rawAudios.get('sm-in'), 1);
// addOneAudio('sm-in', this.rawAudios.get('sm-in'), 1);
addOneAudio
(
'
touzi
'
,
this
.
rawAudios
.
get
(
'
touzi
'
),
1
);
addOneAudio
(
'
touzi
'
,
this
.
rawAudios
.
get
(
'
touzi
'
),
1
);
addOneAudio
(
'
card
'
,
this
.
rawAudios
.
get
(
'
card
'
),
1
);
addOneAudio
(
'
card
'
,
this
.
rawAudios
.
get
(
'
card
'
),
1
);
addOneAudio
(
'
start
'
,
this
.
rawAudios
.
get
(
'
start
'
),
1
);
addOneAudio
(
'
start
'
,
this
.
rawAudios
.
get
(
'
start
'
),
1
);
// this.successAudio.onended = () => {
// this.successAudio.onended = () => {
// // this.showSuccessAudio();
// // this.showSuccessAudio();
...
@@ -556,11 +557,11 @@ initImg() {
...
@@ -556,11 +557,11 @@ initImg() {
const
arr
=
this
.
data
.
contentObj
.
picArr
;
const
arr
=
this
.
data
.
contentObj
.
picArr
;
if
(
arr
)
{
if
(
arr
)
{
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
addPicUrl
(
arr
[
i
].
pic_url
);
addPicUrl
(
arr
[
i
].
pic_url
);
}
}
}
}
...
@@ -568,7 +569,7 @@ initImg() {
...
@@ -568,7 +569,7 @@ initImg() {
// 预加载资源
// 预加载资源
this
.
loadResources
().
then
(()
=>
{
this
.
loadResources
().
then
(()
=>
{
window
[
"
air
"
].
hideAirClassLoading
(
"
ball
"
,
this
.
data
);
window
[
"
air
"
].
hideAirClassLoading
(
"
ball
"
,
this
.
data
);
// this.setfontData();
// this.setfontData();
this
.
init
();
this
.
init
();
...
@@ -604,9 +605,9 @@ initImg() {
...
@@ -604,9 +605,9 @@ initImg() {
// this.mapScale = this.canvasWidth / this.canvasBaseW;
// this.mapScale = this.canvasWidth / this.canvasBaseW;
// this.mapScale = this.canvasHeight / this.canvasBaseH;
// this.mapScale = this.canvasHeight / this.canvasBaseH;
this
.
renderArr
=
[];
this
.
renderArr
=
[];
this
.
isStart
=
false
;
if
(
!
this
.
data
.
contentObj
.
picArr
)
{
if
(
!
this
.
data
.
contentObj
.
picArr
)
{
...
@@ -624,7 +625,7 @@ initImg() {
...
@@ -624,7 +625,7 @@ initImg() {
/**
/**
* 初始化试图
* 初始化试图
*/
*/
initView
()
{
initView
()
{
//加背景
//加背景
this
.
initBg
();
this
.
initBg
();
//加流星
//加流星
...
@@ -640,25 +641,25 @@ initImg() {
...
@@ -640,25 +641,25 @@ initImg() {
a
a
big
(){
big
(){
const
tween
=
tweenChange
(
this
.
tz
,
{
scaleX
:
1.1
,
scaleY
:
1.1
},
1
,
()
=>
{
const
tween
=
tweenChange
(
this
.
tz
,
{
scaleX
:
1.1
,
scaleY
:
1.1
},
1
,
()
=>
{
this
.
small
();
this
.
small
();
});
});
this
.
a
=
tween
;
this
.
a
=
tween
;
}
}
w
w
small
(){
small
(){
const
tween
=
tweenChange
(
this
.
tz
,
{
scaleX
:
1
,
scaleY
:
1
},
1
,
()
=>
{
const
tween
=
tweenChange
(
this
.
tz
,
{
scaleX
:
1
,
scaleY
:
1
},
1
,
()
=>
{
this
.
big
();
this
.
big
();
});
});
this
.
w
=
tween
;
this
.
w
=
tween
;
}
}
...
@@ -667,19 +668,19 @@ small(){
...
@@ -667,19 +668,19 @@ small(){
stouzi
(){
stouzi
(){
//声明骰子
//声明骰子
this
.
tz
=
new
MySprite
();
this
.
tz
=
new
MySprite
();
this
.
t
=
new
MySprite
();
this
.
t
=
new
MySprite
();
this
.
tz
.
addChild
(
this
.
t
);
this
.
tz
.
addChild
(
this
.
t
);
this
.
t
.
init
(
this
.
images
.
get
(
"
t1
"
));
this
.
t
.
init
(
this
.
images
.
get
(
"
t1
"
));
// this.startBorder.addChild(this.tz);
// this.startBorder.addChild(this.tz);
this
.
tz
.
setScaleXY
(
this
.
mapScale
/
1.2
);
this
.
tz
.
setScaleXY
(
this
.
mapScale
/
1.2
);
this
.
tz
.
y
=
this
.
canvasHeight
/
2.5
;
this
.
tz
.
y
=
this
.
canvasHeight
/
2.5
;
this
.
tz
.
x
=
this
.
canvasWidth
/
2
;
this
.
tz
.
x
=
this
.
canvasWidth
/
2
;
this
.
renderArr
.
push
(
this
.
tz
);
this
.
renderArr
.
push
(
this
.
tz
);
}
}
Btn
Btn
...
@@ -687,7 +688,7 @@ stn
...
@@ -687,7 +688,7 @@ stn
retn
retn
startBtn
(){
startBtn
(){
const
allwidth
=
((
this
.
cardArr
.
length
/
2
)
*
280
+
(
this
.
cardArr
.
length
/
2
-
1
)
*
56
)
*
this
.
mapScale
;
const
allwidth
=
((
this
.
cardArr
.
length
/
2
)
*
280
+
(
this
.
cardArr
.
length
/
2
-
1
)
*
56
)
*
this
.
mapScale
;
this
.
Btn
=
new
MySprite
();
this
.
Btn
=
new
MySprite
();
...
@@ -702,7 +703,7 @@ startBtn(){
...
@@ -702,7 +703,7 @@ startBtn(){
// this.startBorder.addChild(this.Btn);
// this.startBorder.addChild(this.Btn);
this
.
stn
.
visible
=
true
;
this
.
stn
.
visible
=
true
;
this
.
retn
.
visible
=
false
;
this
.
retn
.
visible
=
false
;
this
.
Btn
.
setScaleXY
(
this
.
mapScale
/
1.5
);
this
.
Btn
.
setScaleXY
(
this
.
mapScale
/
1.5
);
this
.
b
=
0
;
this
.
b
=
0
;
this
.
Btn
.
y
=
this
.
canvasHeight
/
1.2
;
this
.
Btn
.
y
=
this
.
canvasHeight
/
1.2
;
...
@@ -711,9 +712,9 @@ startBtn(){
...
@@ -711,9 +712,9 @@ startBtn(){
}
}
s1
s1
Animation
(){
Animation
(){
...
@@ -726,7 +727,7 @@ Animation(){
...
@@ -726,7 +727,7 @@ Animation(){
this
.
s1
.
y
=-
1.2
*
this
.
canvasHeight
;
this
.
s1
.
y
=-
1.2
*
this
.
canvasHeight
;
this
.
startBorder
.
addChild
(
this
.
s1
);
this
.
startBorder
.
addChild
(
this
.
s1
);
const
randomT
=
9
;
const
randomT
=
9
;
this
.
s1
[
'
time
'
]
=
randomT
;
this
.
s1
[
'
time
'
]
=
randomT
;
moveItem
(
this
.
s1
,
-
(
this
.
canvasWidth
+
this
.
s1
.
width
*
this
.
s1
.
scaleX
),
this
.
canvasHeight
+
this
.
s1
.
height
*
this
.
s1
.
scaleY
,
this
.
s1
[
'
time
'
],
()
=>
{
moveItem
(
this
.
s1
,
-
(
this
.
canvasWidth
+
this
.
s1
.
width
*
this
.
s1
.
scaleX
),
this
.
canvasHeight
+
this
.
s1
.
height
*
this
.
s1
.
scaleY
,
this
.
s1
[
'
time
'
],
()
=>
{
...
@@ -735,7 +736,7 @@ Animation(){
...
@@ -735,7 +736,7 @@ Animation(){
setTimeout
(()
=>
{
setTimeout
(()
=>
{
this
.
Animation
();
this
.
Animation
();
},
2000
);
},
2000
);
...
@@ -791,166 +792,171 @@ getPetal() {
...
@@ -791,166 +792,171 @@ getPetal() {
bg
bg
startBorder
startBorder
bgLayer
bgLayer
count
=
0
;
count
=
0
;
active
=
1
;
active
=
1
;
last
last
mapDown
(
event
)
{
mapDown
(
event
)
{
if
(
!
this
.
canTouch
)
{
if
(
!
this
.
canTouch
)
{
return
;
return
;
}
}
//点击开始按钮,骰子竖直跳下来,卡片弹出来
//点击开始按钮,骰子竖直跳下来,卡片弹出来
if
(
this
.
checkClickTarget
(
this
.
stn
)
&&
(
this
.
b
==
0
))
{
if
(
!
this
.
isStart
)
{
this
.
canTouch
=
false
;
if
(
this
.
checkClickTarget
(
this
.
stn
)
&&
(
this
.
b
==
0
))
{
this
.
canTouch
=
false
;
this
.
big
();
this
.
startGame
();
this
.
big
();
setTimeout
(()
=>
{
this
.
startGame
();
this
.
canTouch
=
true
;
setTimeout
(()
=>
{
this
.
canTouch
=
true
;
},
1600
);
},
1600
);
// return;
this
.
isStart
=
true
;
}
return
;
return
;
}
}
//点击重新开始按钮
//点击重新开始按钮
if
(
this
.
checkClickTarget
(
this
.
retn
)
&&
(
this
.
b
==
1
))
{
if
(
this
.
checkClickTarget
(
this
.
retn
)
&&
(
this
.
b
==
1
))
{
this
.
canTouch
=
false
;
this
.
canTouch
=
false
;
for
(
let
i
=
0
;
i
<
this
.
cardArr
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
this
.
cardArr
.
length
;
i
++
){
tweenChange
(
this
.
cardArr
[
i
],
{
scaleX
:
0
,
scaleY
:
0
},
0.3
,
()
=>
{
tweenChange
(
this
.
cardArr
[
i
],
{
scaleX
:
0
,
scaleY
:
0
},
0.3
,
()
=>
{
});
});
}
}
this
.
tz
.
visible
=
true
;
this
.
tz
.
visible
=
true
;
this
.
tz
.
setScaleXY
(
this
.
mapScale
/
1.5
);
this
.
tz
.
setScaleXY
(
this
.
mapScale
/
1.5
);
this
.
tz
.
y
=-
50
;
this
.
tz
.
y
=-
50
;
// this.big();
// this.big();
this
.
startGame
();
this
.
startGame
();
setTimeout
(()
=>
{
setTimeout
(()
=>
{
this
.
canTouch
=
true
;
this
.
canTouch
=
true
;
},
1600
);
},
1600
);
}
}
//点击骰子,随机选卡]
//点击骰子,随机选卡]
if
(
this
.
checkClickTarget
(
this
.
t
))
{
if
(
this
.
checkClickTarget
(
this
.
t
))
{
this
.
canTouch
=
false
;
this
.
canTouch
=
false
;
this
.
a
.
stop
();
this
.
a
.
stop
();
this
.
w
.
stop
();
this
.
w
.
stop
();
this
.
starttouzi
();
this
.
starttouzi
();
setTimeout
(()
=>
{
setTimeout
(()
=>
{
this
.
canTouch
=
true
;
this
.
canTouch
=
true
;
},
1900
);
},
1900
);
return
;
return
;
}
}
//点击图片正面的动作
//点击图片正面的动作
for
(
let
i
=
0
;
i
<
this
.
cardArr
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
this
.
cardArr
.
length
;
i
++
){
let
card
=
this
.
cardArr
[
i
];
let
card
=
this
.
cardArr
[
i
];
let
cardBg
=
card
.
children
[
1
];
let
cardBg
=
card
.
children
[
1
];
console
.
log
(
"
i
"
+
i
);
console
.
log
(
"
i
"
+
i
);
if
(
this
.
checkClickTarget
(
cardBg
)
&&
(
this
.
bs
[
i
]
==
1
)){
if
(
this
.
checkClickTarget
(
cardBg
)
&&
(
this
.
bs
[
i
]
==
1
)){
console
.
log
(
"
contc
"
+
this
.
countc
);
console
.
log
(
"
contc
"
+
this
.
countc
);
this
.
countc
++
;
this
.
countc
++
;
let
lcard
;
let
lcard
;
lcard
=
this
.
cardArr
[
this
.
x
];
lcard
=
this
.
cardArr
[
this
.
x
];
if
(
this
.
countc
==
1
){
if
(
this
.
countc
==
1
){
}
}
else
{
else
{
const
audio
=
this
.
audioObj
[
lcard
[
"
audio_url
"
]];
const
audio
=
this
.
audioObj
[
lcard
[
"
audio_url
"
]];
audio
.
pause
();
audio
.
pause
();
audio
.
currentTime
=
0
;
audio
.
currentTime
=
0
;
}
}
this
.
playAudio
(
card
[
"
audio_url
"
]);
this
.
playAudio
(
card
[
"
audio_url
"
]);
this
.
x
=
i
;
this
.
x
=
i
;
console
.
log
(
"
i-
"
+
i
);
console
.
log
(
"
i-
"
+
i
);
this
.
playAudio
(
card
[
"
audio_url
"
]);
this
.
playAudio
(
card
[
"
audio_url
"
]);
return
;
return
;
}
}
}
}
}
}
countc
=
0
;
countc
=
0
;
x
x
starttouzi
(){
starttouzi
(){
this
.
count
++
;
this
.
count
++
;
//骰子转动,给一个随机数
//骰子转动,给一个随机数
this
.
canTouch
=
false
;
this
.
canTouch
=
false
;
this
.
tAnimation
();
this
.
tAnimation
();
if
(
this
.
count
!=
1
){
if
(
this
.
count
!=
1
){
hideItem
(
this
.
faguang
[
this
.
last
]);
hideItem
(
this
.
faguang
[
this
.
last
]);
}
}
if
(
this
.
count
==
6
){
if
(
this
.
count
==
6
){
this
.
canTouch
=
false
;
this
.
canTouch
=
false
;
this
.
count
=
0
;
this
.
count
=
0
;
setTimeout
(()
=>
{
setTimeout
(()
=>
{
//骰子消失
//骰子消失
// hideItem(this.tz);
// hideItem(this.tz);
this
.
tz
.
visible
=
false
;
this
.
tz
.
visible
=
false
;
//重新开始按钮
//重新开始按钮
this
.
stn
.
visible
=
false
;
this
.
stn
.
visible
=
false
;
this
.
retn
.
visible
=
true
;
this
.
retn
.
visible
=
true
;
this
.
b
=
1
;
this
.
b
=
1
;
setTimeout
(()
=>
{
setTimeout
(()
=>
{
tweenChange
(
this
.
Btn
,
{
scaleX
:
1
,
scaleY
:
1
},
0.3
,
()
=>
{
tweenChange
(
this
.
Btn
,
{
scaleX
:
1
,
scaleY
:
1
},
0.3
,
()
=>
{
});
});
},
180
);
},
180
);
},
1300
);
},
1300
);
}
}
}
}
b
b
btnIn1
(
item
){
btnIn1
(
item
){
...
@@ -964,74 +970,74 @@ bgLayer
...
@@ -964,74 +970,74 @@ bgLayer
}
}
//开始游戏
//开始游戏
startGame
(){
startGame
(){
this
.
canTouch
=
false
;
this
.
canTouch
=
false
;
this
.
playAudio
(
"
start
"
);
this
.
playAudio
(
"
start
"
);
//生成随机数组
//生成随机数组
if
(
this
.
count
==
0
){
if
(
this
.
count
==
0
){
this
.
randomtz
();
this
.
randomtz
();
}
}
//按钮消失
//按钮消失
tweenChange
(
this
.
Btn
,
{
scaleX
:
1.2
,
scaleY
:
1.2
},
0.3
,
()
=>
{
tweenChange
(
this
.
Btn
,
{
scaleX
:
1.2
,
scaleY
:
1.2
},
0.3
,
()
=>
{
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
tweenChange
(
this
.
Btn
,
{
scaleX
:
0
,
scaleY
:
0
},
0.3
,
()
=>
{
tweenChange
(
this
.
Btn
,
{
scaleX
:
0
,
scaleY
:
0
},
0.3
,
()
=>
{
});
});
},
180
);
},
180
);
//卡片弹出来
//卡片弹出来
setTimeout
(()
=>
{
setTimeout
(()
=>
{
this
.
initCard
();
this
.
initCard
();
},
180
);
},
180
);
//骰子掉下来
//骰子掉下来
setTimeout
(()
=>
{
setTimeout
(()
=>
{
this
.
touzi
();
this
.
touzi
();
},
300
);
},
300
);
}
}
tz
tz
t
;
t
;
randomt
randomt
touzi
(){
touzi
(){
//骰子掉下来
//骰子掉下来
this
.
btnIn1
(
this
.
tz
);
this
.
btnIn1
(
this
.
tz
);
}
}
fancard
(){
fancard
(){
this
.
overCard
(
this
.
cardArr
[
this
.
randomt
],()
=>
{
this
.
overCard
(
this
.
cardArr
[
this
.
randomt
],()
=>
{
});
});
}
}
tAnimation
(){
tAnimation
(){
this
.
randomt
=
this
.
newball
[
0
];
this
.
randomt
=
this
.
newball
[
0
];
this
.
playAudio
(
"
touzi
"
);
this
.
playAudio
(
"
touzi
"
);
console
.
log
(
"
this.a
"
+
this
.
a
);
console
.
log
(
"
this.a
"
+
this
.
a
);
const
animation
=
new
MyAnimation
();
const
animation
=
new
MyAnimation
();
for
(
let
j
=
0
;
j
<
2
;
j
++
){
for
(
let
j
=
0
;
j
<
2
;
j
++
){
for
(
let
i
=
0
;
i
<
6
;
i
++
){
for
(
let
i
=
0
;
i
<
6
;
i
++
){
const
imgobj
=
this
.
images
.
get
(
'
touzi
'
+
i
);
const
imgobj
=
this
.
images
.
get
(
'
touzi
'
+
i
);
animation
.
addFrameByImg
(
imgobj
);
animation
.
addFrameByImg
(
imgobj
);
}
}
}
}
animation
.
delayPerUnit
=
0.09
;
animation
.
delayPerUnit
=
0.09
;
//骰子旋转
//骰子旋转
animation
.
play
();
animation
.
play
();
animation
.
playEnd
=
()
=>
{
animation
.
playEnd
=
()
=>
{
if
(
this
.
data
.
sideA
==
1
)
if
(
this
.
data
.
sideA
==
1
)
{
{
...
@@ -1041,51 +1047,51 @@ bgLayer
...
@@ -1041,51 +1047,51 @@ bgLayer
if
(
this
.
data
.
sideB
==
1
){
if
(
this
.
data
.
sideB
==
1
){
this
.
bs
[
this
.
randomt
]
=
1
;
this
.
bs
[
this
.
randomt
]
=
1
;
}
}
animation
.
stop
();
animation
.
stop
();
let
x
=
3
;
let
x
=
3
;
// this.t.init(this.images.get("t"+x));
// this.t.init(this.images.get("t"+x));
this
.
t
.
init
(
this
.
images
.
get
(
"
t
"
+
(
this
.
randomt
+
1
)));
this
.
t
.
init
(
this
.
images
.
get
(
"
t
"
+
(
this
.
randomt
+
1
)));
alphaItem
(
this
.
faguang
[
this
.
randomt
],
1
);
alphaItem
(
this
.
faguang
[
this
.
randomt
],
1
);
this
.
last
=
this
.
randomt
;
this
.
last
=
this
.
randomt
;
this
.
overCard
(
this
.
cardArr
[
this
.
randomt
],()
=>
{
this
.
overCard
(
this
.
cardArr
[
this
.
randomt
],()
=>
{
//发光特效
//发光特效
//this.cardArr[this.randomt].faguang.visible=true;
//this.cardArr[this.randomt].faguang.visible=true;
// this.cardArr[this.randomt].children[]
// this.cardArr[this.randomt].children[]
let
rect
=
this
.
cardArr
[
this
.
randomt
].
getBoundingBox
();
let
rect
=
this
.
cardArr
[
this
.
randomt
].
getBoundingBox
();
rect
.
x
=
this
.
cardArr
[
this
.
randomt
].
x
-
120
;
rect
.
x
=
this
.
cardArr
[
this
.
randomt
].
x
-
120
;
rect
.
y
=
this
.
cardArr
[
this
.
randomt
].
y
-
140
;
rect
.
y
=
this
.
cardArr
[
this
.
randomt
].
y
-
140
;
rect
.
width
=
250
;
rect
.
width
=
250
;
rect
.
height
=
250
;
rect
.
height
=
250
;
showBlingBling
(
this
.
images
.
get
(
'
ss
'
),
rect
,
this
.
bgLayer
,
this
.
mapScale
*
1.5
,
1
,
0.05
,
1.5
);
showBlingBling
(
this
.
images
.
get
(
'
ss
'
),
rect
,
this
.
bgLayer
,
this
.
mapScale
*
1.5
,
1
,
0.05
,
1.5
);
});
});
this
.
newball
.
splice
(
0
,
1
);
this
.
newball
.
splice
(
0
,
1
);
this
.
a
.
start
();
this
.
a
.
start
();
this
.
w
.
start
();
this
.
w
.
start
();
};
};
this
.
tz
.
addChild
(
animation
);
this
.
tz
.
addChild
(
animation
);
}
}
ss1
ss1
ss2
ss2
ss3
ss3
ss4
ss4
oldball
oldball
newball
newball
randomtz
(){
randomtz
(){
...
@@ -1095,12 +1101,12 @@ bgLayer
...
@@ -1095,12 +1101,12 @@ bgLayer
}
}
endPageArr
;
endPageArr
;
showPetalFlag
;
showPetalFlag
;
initCard
(){
initCard
(){
this
.
randomItemCard
();
this
.
randomItemCard
();
// this.cardArr = randomSortByArr(this.cardArr); //重新排序卡片组
// this.cardArr = randomSortByArr(this.cardArr); //重新排序卡片组
this
.
initItemCard
();
//设定卡片的位置
this
.
initItemCard
();
//设定卡片的位置
//卡片恢复之前的状态
//卡片恢复之前的状态
for
(
let
i
=
0
;
i
<
this
.
cardArr
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
this
.
cardArr
.
length
;
i
++
){
let
card
=
this
.
cardArr
[
i
];
let
card
=
this
.
cardArr
[
i
];
...
@@ -1110,47 +1116,47 @@ bgLayer
...
@@ -1110,47 +1116,47 @@ bgLayer
this
.
StartAnimation
(
this
.
cardArr
);
this
.
StartAnimation
(
this
.
cardArr
);
}
}
initItemCard
(){
initItemCard
(){
const
picLength
=
this
.
cardArr
.
length
;
const
picLength
=
this
.
cardArr
.
length
;
const
top
=
(
120
)
*
this
.
mapScale
;
//卡片第一排距离头顶的距离
const
top
=
(
120
)
*
this
.
mapScale
;
//卡片第一排距离头顶的距离
const
top2
=
(
212
+
160
)
*
this
.
mapScale
;
//卡片第二排距离头顶的距离
const
top2
=
(
212
+
160
)
*
this
.
mapScale
;
//卡片第二排距离头顶的距离
const
allWidth
=
((
picLength
/
2
)
*
280
+
(
picLength
/
2
-
1
)
*
80
)
*
this
.
mapScale
;
//卡片总宽
const
allWidth
=
((
picLength
/
2
)
*
280
+
(
picLength
/
2
-
1
)
*
80
)
*
this
.
mapScale
;
//卡片总宽
const
drawItem
=
(
index
)
=>
{
const
drawItem
=
(
index
)
=>
{
//设置卡片间距
//设置卡片间距
let
itemBack
=
this
.
cardArr
[
index
];
let
itemBack
=
this
.
cardArr
[
index
];
if
(
index
<
3
){
if
(
index
<
3
){
itemBack
.
y
=
top
;
itemBack
.
y
=
top
;
itemBack
.
x
=
(
this
.
canvasWidth
-
allWidth
)
/
2
+
(((
index
)
*
(
253
+
55
))
+
200
)
*
this
.
mapScale
;
//剩余的宽加
itemBack
.
x
=
(
this
.
canvasWidth
-
allWidth
)
/
2
+
(((
index
)
*
(
253
+
55
))
+
200
)
*
this
.
mapScale
;
//剩余的宽加
}
else
{
}
else
{
itemBack
.
y
=
top2
;
itemBack
.
y
=
top2
;
itemBack
.
x
=
(
this
.
canvasWidth
-
allWidth
)
/
2
+
(((
index
-
3
)
*
(
253
+
55
))
+
200
)
*
this
.
mapScale
;
//剩余的宽加
itemBack
.
x
=
(
this
.
canvasWidth
-
allWidth
)
/
2
+
(((
index
-
3
)
*
(
253
+
55
))
+
200
)
*
this
.
mapScale
;
//剩余的宽加
}
}
itemBack
.
setScaleXY
(
this
.
mapScale
);
itemBack
.
setScaleXY
(
this
.
mapScale
);
this
.
renderArr
.
push
(
itemBack
);
this
.
renderArr
.
push
(
itemBack
);
};
};
for
(
let
i
=
0
;
i
<
6
;
i
++
){
for
(
let
i
=
0
;
i
<
6
;
i
++
){
drawItem
(
i
);
drawItem
(
i
);
}
}
}
}
StartAnimation
(
cardArr
){
StartAnimation
(
cardArr
){
//卡片渐进显示
//卡片渐进显示
/*for(let i=0;i<cardArr.length;i++){
/*for(let i=0;i<cardArr.length;i++){
tweenChange(cardArr[i], {alpha: 1}, 0.3, ()=>{
tweenChange(cardArr[i], {alpha: 1}, 0.3, ()=>{
...
@@ -1159,24 +1165,24 @@ bgLayer
...
@@ -1159,24 +1165,24 @@ bgLayer
this.overCard(cardArr[i],()=>{
this.overCard(cardArr[i],()=>{
this.canTouch = true;
this.canTouch = true;
});
});
}, 1000);
}, 1000);
});
});
}*/
}*/
for
(
let
i
=
0
;
i
<
cardArr
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
cardArr
.
length
;
i
++
){
tweenChange
(
cardArr
[
i
],
{
scaleX
:
0
,
scaleY
:
0
},
0
,
()
=>
{
tweenChange
(
cardArr
[
i
],
{
scaleX
:
0
,
scaleY
:
0
},
0
,
()
=>
{
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
tweenChange
(
cardArr
[
i
],
{
scaleX
:
0.5
,
scaleY
:
0.5
},
0.3
);
tweenChange
(
cardArr
[
i
],
{
scaleX
:
0.5
,
scaleY
:
0.5
},
0.3
);
},
1000
);
},
1000
);
}
}
}
}
overCard
(
item
,
callback
?:
any
){
overCard
(
item
,
callback
?:
any
){
let
w
=
item
.
scaleX
;
let
w
=
item
.
scaleX
;
this
.
playAudio
(
"
card
"
);
this
.
playAudio
(
"
card
"
);
tweenChange
(
item
,
{
scaleX
:
0
},
0.3
,()
=>
{
tweenChange
(
item
,
{
scaleX
:
0
},
0.3
,()
=>
{
...
@@ -1191,97 +1197,97 @@ bgLayer
...
@@ -1191,97 +1197,97 @@ bgLayer
back
=
[]
back
=
[]
bs
=
[];
bs
=
[];
faguang
=
[]
faguang
=
[]
randomItemCard
(){
randomItemCard
(){
this
.
cardArr
=
[];
this
.
cardArr
=
[];
for
(
let
i
=
0
;
i
<
6
;
i
++
){
for
(
let
i
=
0
;
i
<
6
;
i
++
){
let
item
=
this
.
picArr
[
i
];
let
item
=
this
.
picArr
[
i
];
let
pic
=
new
MySprite
();
let
pic
=
new
MySprite
();
//初始化设置为隐藏
//初始化设置为隐藏
pic
.
alpha
=
1
;
pic
.
alpha
=
1
;
pic
.
childDepandAlpha
=
true
;
pic
.
childDepandAlpha
=
true
;
//声明正反面的对象
//声明正反面的对象
this
.
back
[
i
]
=
new
MySprite
();
this
.
back
[
i
]
=
new
MySprite
();
this
.
front
[
i
]
=
new
MySprite
();
this
.
front
[
i
]
=
new
MySprite
();
this
.
faguang
[
i
]
=
new
MySprite
();
this
.
faguang
[
i
]
=
new
MySprite
();
this
.
faguang
[
i
].
alpha
=
0
;
this
.
faguang
[
i
].
alpha
=
0
;
//设置索引
//设置索引
pic
[
"
index
"
]
=
i
;
pic
[
"
index
"
]
=
i
;
this
.
faguang
[
i
].
init
(
this
.
images
.
get
(
"
发光
"
));
this
.
faguang
[
i
].
init
(
this
.
images
.
get
(
"
发光
"
));
let
bgRect
=
new
ShapeRect
();
let
bgRect
=
new
ShapeRect
();
bgRect
.
setSize
(
390
,
390
);
bgRect
.
setSize
(
390
,
390
);
bgRect
.
init
();
bgRect
.
init
();
bgRect
.
fillColor
=
'
#ff83fa
'
;
bgRect
.
fillColor
=
'
#ff83fa
'
;
this
.
front
[
i
].
addChild
(
bgRect
,
-
1
);
this
.
front
[
i
].
addChild
(
bgRect
,
-
1
);
this
.
q
=
bgRect
;
this
.
q
=
bgRect
;
//把设置好的正反面变量放到卡片组里
//把设置好的正反面变量放到卡片组里
if
(
this
.
data
.
sideA
==
1
){
if
(
this
.
data
.
sideA
==
1
){
//如果选择默认是正面,bs=0
//如果选择默认是正面,bs=0
for
(
let
i
=
0
;
i
<
this
.
picArr
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
this
.
picArr
.
length
;
i
++
){
this
.
bs
[
i
]
=
1
;
this
.
bs
[
i
]
=
1
;
}
}
pic
.
addChild
(
this
.
back
[
i
]);
pic
.
addChild
(
this
.
back
[
i
]);
pic
.
addChild
(
this
.
front
[
i
]);
pic
.
addChild
(
this
.
front
[
i
]);
}
}
else
if
(
this
.
data
.
sideB
==
1
){
else
if
(
this
.
data
.
sideB
==
1
){
for
(
let
i
=
0
;
i
<
this
.
picArr
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
this
.
picArr
.
length
;
i
++
){
this
.
bs
[
i
]
=
0
;
this
.
bs
[
i
]
=
0
;
}
}
pic
.
addChild
(
this
.
front
[
i
]);
pic
.
addChild
(
this
.
front
[
i
]);
pic
.
addChild
(
this
.
back
[
i
]);
pic
.
addChild
(
this
.
back
[
i
]);
}
}
//音频路径做属性保存,方便点击卡片播放
//音频路径做属性保存,方便点击卡片播放
if
(
item
.
audio_url
){
if
(
item
.
audio_url
){
pic
[
"
audio_url
"
]
=
item
.
audio_url
;
pic
[
"
audio_url
"
]
=
item
.
audio_url
;
console
.
log
(
item
.
audio_url
+
"
pic-audio
"
);
console
.
log
(
item
.
audio_url
+
"
pic-audio
"
);
}
}
const
maxLen
=
400
;
const
maxLen
=
400
;
if
(
item
.
pic_url
){
if
(
item
.
pic_url
){
let
pic
=
new
MySprite
();
let
pic
=
new
MySprite
();
pic
.
init
(
this
.
images
.
get
(
item
.
pic_url
));
pic
.
init
(
this
.
images
.
get
(
item
.
pic_url
));
//如果是横图设置图片填充卡片正面的比例
//如果是横图设置图片填充卡片正面的比例
if
(
pic
.
width
>
pic
.
height
){
if
(
pic
.
width
>
pic
.
height
){
pic
.
setScaleXY
(
getMinScale
(
pic
,
maxLen
));
pic
.
setScaleXY
(
getMinScale
(
pic
,
maxLen
));
pic
.
x
=
2
;
pic
.
x
=
2
;
this
.
front
[
i
].
addChild
(
pic
);
this
.
front
[
i
].
addChild
(
pic
);
}
}
//如果是竖图设置图片填充卡片正面的比例
//如果是竖图设置图片填充卡片正面的比例
if
(
pic
.
width
<=
pic
.
height
&&
(
pic
.
width
+
40
)
>=
pic
.
height
){
if
(
pic
.
width
<=
pic
.
height
&&
(
pic
.
width
+
40
)
>=
pic
.
height
){
pic
.
setScaleXY
(
getMinScale
(
pic
,
maxLen
-
80
));
pic
.
setScaleXY
(
getMinScale
(
pic
,
maxLen
-
80
));
pic
.
x
=
0
;
pic
.
x
=
0
;
pic
.
y
=-
3
;
pic
.
y
=-
3
;
}
}
//如果是正方图设置图片填充卡片正面的比例
//如果是正方图设置图片填充卡片正面的比例
if
(
pic
.
width
<=
pic
.
height
&&
(
pic
.
width
+
40
)
<
pic
.
height
){
if
(
pic
.
width
<=
pic
.
height
&&
(
pic
.
width
+
40
)
<
pic
.
height
){
pic
.
setScaleXY
(
getMinScale
(
pic
,
maxLen
-
60
));
pic
.
setScaleXY
(
getMinScale
(
pic
,
maxLen
-
60
));
pic
.
x
=-
5
;
pic
.
x
=-
5
;
pic
.
y
=-
6
;
pic
.
y
=-
6
;
}
}
this
.
front
[
i
].
addChild
(
pic
);
this
.
front
[
i
].
addChild
(
pic
);
}
else
{
}
else
{
const
label
=
new
Label
();
const
label
=
new
Label
();
label
.
text
=
item
.
title
;
label
.
text
=
item
.
title
;
...
@@ -1289,18 +1295,18 @@ bgLayer
...
@@ -1289,18 +1295,18 @@ bgLayer
label
.
fontColor
=
'
#ed3a33
'
;
label
.
fontColor
=
'
#ed3a33
'
;
label
.
fontSize
=
200
;
label
.
fontSize
=
200
;
label
.
textAlign
=
'
center
'
;
label
.
textAlign
=
'
center
'
;
label
.
setMaxSize
((
bgRect
.
width
-
20
)
+
10
);
label
.
setMaxSize
((
bgRect
.
width
-
20
)
+
10
);
console
.
log
(
bgRect
.
width
-
20
+
"
卡片文字位置
"
);
console
.
log
(
bgRect
.
width
-
20
+
"
卡片文字位置
"
);
this
.
front
[
i
].
addChild
(
label
);
this
.
front
[
i
].
addChild
(
label
);
}
}
this
.
front
[
i
].
addChild
(
this
.
faguang
[
i
],
-
1
);
this
.
front
[
i
].
addChild
(
this
.
faguang
[
i
],
-
1
);
this
.
back
[
i
].
addChild
(
this
.
faguang
[
i
],
-
1
);
this
.
back
[
i
].
addChild
(
this
.
faguang
[
i
],
-
1
);
this
.
cardArr
.
push
(
pic
);
this
.
cardArr
.
push
(
pic
);
this
.
cardArr
[
i
].
alpha
=
1
;
this
.
cardArr
[
i
].
alpha
=
1
;
}
}
this
.
back
[
0
].
init
(
this
.
images
.
get
(
"
back0
"
));
this
.
back
[
0
].
init
(
this
.
images
.
get
(
"
back0
"
));
this
.
back
[
4
].
init
(
this
.
images
.
get
(
"
back0
"
));
this
.
back
[
4
].
init
(
this
.
images
.
get
(
"
back0
"
));
this
.
back
[
1
].
init
(
this
.
images
.
get
(
"
back1
"
));
this
.
back
[
1
].
init
(
this
.
images
.
get
(
"
back1
"
));
...
@@ -1313,19 +1319,19 @@ bgLayer
...
@@ -1313,19 +1319,19 @@ bgLayer
this
.
front
[
5
].
init
(
this
.
images
.
get
(
"
front1
"
));
this
.
front
[
5
].
init
(
this
.
images
.
get
(
"
front1
"
));
this
.
front
[
3
].
init
(
this
.
images
.
get
(
"
front2
"
));
this
.
front
[
3
].
init
(
this
.
images
.
get
(
"
front2
"
));
this
.
front
[
2
].
init
(
this
.
images
.
get
(
"
front2
"
));
this
.
front
[
2
].
init
(
this
.
images
.
get
(
"
front2
"
));
}
}
initBg
()
{
initBg
()
{
this
.
bgLayer
=
new
MySprite
();
this
.
bgLayer
=
new
MySprite
();
this
.
renderArr
.
push
(
this
.
bgLayer
);
this
.
renderArr
.
push
(
this
.
bgLayer
);
const
bg
=
new
ShapeRect
();
const
bg
=
new
ShapeRect
();
bg
.
fillColor
=
'
#75d100
'
;
bg
.
fillColor
=
'
#75d100
'
;
bg
.
setSize
(
this
.
canvasWidth
,
this
.
canvasHeight
);
bg
.
setSize
(
this
.
canvasWidth
,
this
.
canvasHeight
);
this
.
renderArr
.
push
(
bg
);
this
.
renderArr
.
push
(
bg
);
this
.
bg
=
bg
;
this
.
bg
=
bg
;
//把图片填充入背景,全覆盖
//把图片填充入背景,全覆盖
this
.
startBorder
=
new
MySprite
();
this
.
startBorder
=
new
MySprite
();
this
.
startBorder
.
init
(
this
.
images
.
get
(
'
BG
'
));
this
.
startBorder
.
init
(
this
.
images
.
get
(
'
BG
'
));
...
@@ -1336,13 +1342,13 @@ bgLayer
...
@@ -1336,13 +1342,13 @@ bgLayer
const
s
=
Math
.
max
(
sx
,
sy
);
const
s
=
Math
.
max
(
sx
,
sy
);
console
.
log
(
s
+
"
s
"
);
console
.
log
(
s
+
"
s
"
);
this
.
startBorder
.
setScaleXY
(
s
);
this
.
startBorder
.
setScaleXY
(
s
);
this
.
renderArr
.
push
(
this
.
startBorder
);
this
.
renderArr
.
push
(
this
.
startBorder
);
}
}
mapMove
(
event
)
{
mapMove
(
event
)
{
}
}
...
@@ -1373,4 +1379,4 @@ bgLayer
...
@@ -1373,4 +1379,4 @@ bgLayer
}
}
\ No newline at end of file
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