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
fda77d27
Commit
fda77d27
authored
Apr 18, 2020
by
邵世尧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交
parent
d381f1ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
629 additions
and
647 deletions
+629
-647
form.component.html
src/app/form/form.component.html
+4
-4
form.component.ts
src/app/form/form.component.ts
+93
-125
play.component.ts
src/app/play/play.component.ts
+532
-518
No files found.
src/app/form/form.component.html
View file @
fda77d27
<div
class=
"model-content"
>
<div
style=
"position: absolute;left: 100px;top:20px;width: 500px;"
>
<nz-radio-group
[(
ngModel
)]="
side
"
>
<label
nz-radio
nzValue=
"A"
(
click
)="
sideB
()"
>
默认背面
</label>
<label
nz-radio
nzValue=
"B"
(
click
)="
sideA
()"
>
默认正面
</label>
<nz-radio-group
[(
ngModel
)]="
side
"
(
ngModelChange
)="
sidec
()"
>
<label
nz-radio
nzValue=
"A"
>
默认背面
</label>
<label
nz-radio
nzValue=
"B"
>
默认正面
</label>
</nz-radio-group>
<div
*
ngFor=
"let it of picArr; let i = index"
class=
"card-item"
style=
"padding: 0.5vw;"
>
...
...
@@ -27,7 +27,7 @@
<div
*
ngIf=
"it.optionTypeA == 'A'"
style=
"width: 60%"
>
<input
style=
"width: 80%; margin-bottom: 0.5vw"
type=
"text"
nz-input
placeholder=
""
[(
ngModel
)]="
it
.
title
"
(
blur
)="
save
Item
()"
>
<input
style=
"width: 80%; margin-bottom: 0.5vw"
type=
"text"
nz-input
placeholder=
""
[(
ngModel
)]="
it
.
title
"
(
blur
)="
save
()"
>
</div>
...
...
src/app/form/form.component.ts
View file @
fda77d27
import
{
Component
,
EventEmitter
,
Input
,
OnDestroy
,
OnChanges
,
OnInit
,
Output
,
ApplicationRef
,
ChangeDetectorRef
}
from
'
@angular/core
'
;
import
{
Component
,
EventEmitter
,
Input
,
OnDestroy
,
OnChanges
,
OnInit
,
Output
,
ApplicationRef
,
ChangeDetectorRef
,
ViewChild
,
ElementRef
}
from
'
@angular/core
'
;
import
{
NzMessageService
}
from
'
ng-zorro-antd
'
;
...
...
@@ -8,194 +9,162 @@ import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, Ap
styleUrls
:
[
'
./form.component.css
'
]
})
export
class
FormComponent
implements
OnInit
,
OnChanges
,
OnDestroy
{
picArr
=
[];
_item
:
any
;
saveKey
=
'
ssy003
'
;
radioValue
;
side
// @Input()
set
item
(
item
)
{
this
.
_item
=
item
;
// this.init();
}
get
item
()
{
return
this
.
_item
;
}
item
;
@
ViewChild
(
'
videoContainer
'
)
videoContainer
:
ElementRef
;
@
ViewChild
(
'
videoNode
'
)
videoNode
:
ElementRef
;
@
Output
()
update
=
new
EventEmitter
();
intervalId
;
picArr
;
side
saveKey
=
'
ssy003
'
;
constructor
(
private
appRef
:
ApplicationRef
,
private
changeDetectorRef
:
ChangeDetectorRef
)
{
constructor
(
private
nzMessageService
:
NzMessageService
,
private
appRef
:
ApplicationRef
,
public
changeDetectorRef
:
ChangeDetectorRef
)
{
}
ngOnInit
()
{
this
.
item
=
{};
this
.
item
.
contentObj
=
{};
ngOnChanges
()
{
}
ngOnInit
()
{
const
getData
=
(
<
any
>
window
).
courseware
.
getData
;
getData
((
data
)
=>
{
if
(
data
)
{
this
.
item
=
data
;
}
else
{
this
.
item
=
{};
}
if
(
!
this
.
item
.
contentObj
)
{
this
.
item
.
contentObj
=
{};
}
if
(
this
.
item
.
sideA
==
1
){
this
.
side
=
'
B
'
;
}
else
if
(
this
.
item
.
sideB
==
1
){
this
.
side
=
'
A
'
;
}
console
.
log
(
'
~data:
'
,
data
);
this
.
initDefaultData
();
console
.
log
(
'
data:
'
,
data
);
this
.
init
();
this
.
changeDetectorRef
.
markForCheck
();
this
.
changeDetectorRef
.
detectChanges
();
this
.
refresh
();
// this.initDefaultData();
this
.
refresh
();
},
this
.
saveKey
);
// this.initData();
}
ngOnChanges
()
{
}
ngOnDestroy
()
{
}
sidec
(){
if
(
this
.
side
==
"
A
"
){
this
.
item
.
sideA
=
0
;
this
.
item
.
sideB
=
1
;
}
if
(
this
.
side
==
"
B
"
){
this
.
item
.
sideA
=
1
;
this
.
item
.
sideB
=
0
;
}
this
.
save
();
}
initDefaultData
()
{
init
()
{
const
picArr
=
this
.
item
.
contentObj
.
picArr
;
if
(
!
picArr
)
{
const
picArr
=
[];
for
(
let
i
=
0
;
i
<
6
;
i
++
)
{
picArr
.
push
({
pic_url
:
''
,
audio_url
:
''
,
title
:
''
,
sideA
:
''
,
sideB
:
''
});
}
if
(
this
.
item
.
contentObj
.
picArr
)
{
this
.
picArr
=
this
.
item
.
contentObj
.
picArr
;
}
else
{
this
.
picArr
=
this
.
getDefaultPicArr
();
this
.
item
.
contentObj
.
picArr
=
this
.
picArr
;
this
.
item
.
contentObj
.
picArr
=
picArr
;
}
}
console
.
log
(
'
item:
'
,
this
.
item
);
// this.picArr = this.getDefaultPicArr();
// this.item.contentObj.picArr = this.picArr;
// console.log('this.item:;', this.picArr);
}
cardItemData
(){
return
{
title
:
""
,
pic_url
:
""
,
audio_url
:
""
};
ngOnDestroy
()
{
console
.
log
(
'
in ngOnDestory
'
);
}
sideA
(){
this
.
item
.
sideA
=
1
;
this
.
item
.
sideB
=
0
;
this
.
picArr
=
[];
this
.
item
.
contentObj
.
picArr
=
this
.
picArr
;
for
(
let
i
=
0
;
i
<
6
;
i
++
){
let
item
=
this
.
cardItemData
();
this
.
picArr
.
push
(
item
);
}
this
.
saveItem
();
init
()
{
this
.
picArr
=
this
.
item
.
contentObj
.
picArr
||
[];
}
sideB
(){
this
.
item
.
sideB
=
1
;
this
.
item
.
sideA
=
0
;
this
.
picArr
=
[];
this
.
item
.
contentObj
.
picArr
=
this
.
picArr
;
for
(
let
i
=
0
;
i
<
6
;
i
++
){
let
item
=
this
.
cardItemData
();
this
.
picArr
.
push
(
item
);
}
this
.
saveItem
();
console
.
log
(
'
init~data:
'
,
this
.
picArr
);
}
getDefaultPicArr
()
{
let
arr
=
[];
return
arr
;
}
addItem6
()
{
this
.
picArr
=
[];
this
.
item
.
contentObj
.
picArr
=
this
.
picArr
;
for
(
let
i
=
0
;
i
<
6
;
i
++
){
let
item
=
this
.
cardItemData
();
this
.
picArr
.
push
(
item
);
}
this
.
saveItem
();
console
.
log
(
'
init~data:
'
,
this
.
picArr
);
}
onImageUploadSuccessByItem
(
e
,
item
,
id
=
null
)
{
onImageUploadSuccessByItem
(
e
,
item
)
{
item
.
pic_url
=
e
.
url
;
this
.
save
();
}
onAudioUploadSuccessByItem
(
e
,
item
)
{
item
.
audio_url
=
e
.
url
;
this
.
save
();
}
if
(
id
!=
null
)
{
item
[
id
+
'
_pic_url
'
]
=
e
.
url
;
}
else
{
item
.
pic_url
=
e
.
url
;
}
radioClick
(
it
,
radioValue
)
{
it
.
radioValue
=
radioValue
;
this
.
save
();
// this.update.emit(this.item)
;
this
.
saveItem
(
);
// console.log('this.item: ', this.item
);
}
clickCheckBox
()
{
console
.
log
(
'
in clickCheckBox
'
);
this
.
saveItem
();
}
saveItem
()
{
console
.
log
(
'
in saveItem
'
);
onAudioUploadSuccessByItem
(
e
,
item
,
id
=
null
)
{
if
(
id
!=
null
)
{
item
[
id
+
'
_audio_url
'
]
=
e
.
url
;
}
else
{
item
.
audio_url
=
e
.
url
;
}
// this.update.emit(this.item);
this
.
save
();
}
save
()
{
(
<
any
>
window
).
courseware
.
setData
(
this
.
item
,
null
,
this
.
saveKey
);
console
.
log
(
'
side
'
+
this
.
item
);
this
.
refresh
();
}
...
...
@@ -203,8 +172,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
setTimeout
(()
=>
{
this
.
appRef
.
tick
();
},
1
);
console
.
log
(
"
===========================================================================================
"
);
}
}
src/app/play/play.component.ts
View file @
fda77d27
...
...
@@ -28,7 +28,6 @@ export class PlayComponent implements OnInit, OnDestroy {
// 数据
data
;
ctx
;
canvasWidth
=
1280
;
// canvas实际宽度
...
...
@@ -60,14 +59,11 @@ export class PlayComponent implements OnInit, OnDestroy {
saveKey
=
'
ssy003
'
;
picIndex
=
0
;
cardArr
=
[];
picArr
canTouch
=
true
;
canTouch
=
true
;
curPic
;
...
...
@@ -130,9 +126,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this
.
initCtx
();
this
.
initData
();
// this.randomItemCard();
this
.
initView
();
console
.
log
(
"
qqqqqqqqqqqqqqqqqq
"
);
}
...
...
@@ -577,6 +572,8 @@ initImg() {
/**
* 初始化数据
*/
...
...
@@ -600,7 +597,7 @@ initImg() {
this
.
renderArr
=
[];
if
(
!
this
.
data
.
contentObj
.
picArr
)
{
...
...
@@ -629,9 +626,9 @@ initImg() {
//声明骰子
this
.
stouzi
();
//骰子呼吸动画
}
}
a
a
big
(){
const
tween
=
tweenChange
(
this
.
tz
,
{
scaleX
:
1.1
,
scaleY
:
1.1
},
1
,
()
=>
{
...
...
@@ -667,9 +664,12 @@ stouzi(){
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
.
y
=-
50
;
this
.
tz
.
y
=
this
.
canvasHeight
/
2.5
;
this
.
tz
.
x
=
this
.
canvasWidth
/
2
;
this
.
renderArr
.
push
(
this
.
tz
);
}
...
...
@@ -690,12 +690,15 @@ startBtn(){
this
.
Btn
.
addChild
(
this
.
stn
);
this
.
Btn
.
addChild
(
this
.
retn
);
this
.
startBorder
.
addChild
(
this
.
Btn
);
//
this.startBorder.addChild(this.Btn);
this
.
stn
.
visible
=
true
;
this
.
retn
.
visible
=
false
;
this
.
Btn
.
setScaleXY
(
this
.
mapScale
/
1.5
);
this
.
b
=
0
;
this
.
Btn
.
y
=
200
;
this
.
Btn
.
y
=
this
.
canvasHeight
/
1.2
;
this
.
Btn
.
x
=
this
.
canvasWidth
/
2
;
this
.
renderArr
.
push
(
this
.
Btn
);
...
...
@@ -779,547 +782,558 @@ getPetal() {
bg
startBorder
bgLayer
initBg
()
{
this
.
bgLayer
=
new
MySprite
();
this
.
renderArr
.
push
(
this
.
bgLayer
);
const
bg
=
new
ShapeRect
();
bg
.
fillColor
=
'
#75d100
'
;
bg
.
setSize
(
this
.
canvasWidth
,
this
.
canvasHeight
);
this
.
renderArr
.
push
(
bg
);
this
.
bg
=
bg
;
//把图片填充入背景,全覆盖
this
.
startBorder
=
new
MySprite
();
this
.
startBorder
.
init
(
this
.
images
.
get
(
'
BG
'
));
this
.
startBorder
.
x
=
this
.
canvasWidth
/
2
;
this
.
startBorder
.
y
=
this
.
canvasHeight
/
2
;
const
sx
=
this
.
canvasWidth
/
this
.
startBorder
.
width
;
const
sy
=
this
.
canvasHeight
/
this
.
startBorder
.
height
;
const
s
=
Math
.
max
(
sx
,
sy
);
console
.
log
(
s
+
"
s
"
);
this
.
startBorder
.
setScaleXY
(
s
);
this
.
renderArr
.
push
(
this
.
startBorder
);
}
count
=
0
;
active
=
1
;
last
mapDown
(
event
)
{
//点击按钮,骰子竖直跳下来,卡片弹出来
if
(
this
.
checkClickTarget
(
this
.
stn
)
&&
(
this
.
b
==
0
))
{
this
.
canTouch
=
false
;
this
.
big
();
this
.
startGame
();
return
;
}
if
(
this
.
checkClickTarget
(
this
.
retn
)
&&
(
this
.
b
==
1
))
{
console
.
log
(
"
bbbbb
"
+
this
.
b
);
this
.
canTouch
=
false
;
count
=
0
;
active
=
1
;
last
mapDown
(
event
)
{
if
(
!
this
.
canTouch
)
{
return
;
}
for
(
let
i
=
0
;
i
<
this
.
cardArr
.
length
;
i
++
){
tweenChange
(
this
.
cardArr
[
i
],
{
scaleX
:
0
,
scaleY
:
0
},
0.3
,
()
=>
{
});
}
//点击开始按钮,骰子竖直跳下来,卡片弹出来
if
(
this
.
checkClickTarget
(
this
.
stn
)
&&
(
this
.
b
==
0
))
{
this
.
canTouch
=
false
;
this
.
big
();
this
.
startGame
();
setTimeout
(()
=>
{
this
.
canTouch
=
true
;
},
1600
);
return
;
}
//点击重新开始按钮
if
(
this
.
checkClickTarget
(
this
.
retn
)
&&
(
this
.
b
==
1
))
{
this
.
canTouch
=
false
;
for
(
let
i
=
0
;
i
<
this
.
cardArr
.
length
;
i
++
){
tweenChange
(
this
.
cardArr
[
i
],
{
scaleX
:
0
,
scaleY
:
0
},
0.3
,
()
=>
{
});
}
this
.
tz
.
visible
=
true
;
this
.
tz
.
setScaleXY
(
this
.
mapScale
/
1.5
);
this
.
tz
.
y
=-
50
;
// this.big();
this
.
tz
.
visible
=
true
;
this
.
tz
.
setScaleXY
(
this
.
mapScale
/
1.5
);
this
.
tz
.
y
=-
50
;
// this.big();
this
.
startGame
();
setTimeout
(()
=>
{
this
.
canTouch
=
true
;
},
1600
);
this
.
startGame
();
}
//点击骰子,随机选卡]
if
(
this
.
checkClickTarget
(
this
.
t
))
{
console
.
log
(
this
.
canTouch
+
"
-----00000000000
"
);
this
.
a
.
stop
();
this
.
w
.
stop
();
this
.
canTouch
=
false
;
console
.
log
(
this
.
canTouch
+
"
-----0000000000011111111
"
);
this
.
starttouzi
();
}
return
;
}
//点击图片正面的动作
for
(
let
i
=
0
;
i
<
this
.
cardArr
.
length
;
i
++
){
let
card
=
this
.
cardArr
[
i
];
let
cardBg
=
card
.
children
[
1
];
//点击骰子,随机选卡]
console
.
log
(
"
i
"
+
i
);
if
(
this
.
checkClickTarget
(
this
.
t
))
{
this
.
canTouch
=
false
;
if
(
this
.
checkClickTarget
(
cardBg
)
&&
(
this
.
bs
[
i
]
==
1
)){
console
.
log
(
"
contc
"
+
this
.
countc
);
this
.
countc
++
;
let
lcard
;
lcard
=
this
.
cardArr
[
this
.
x
];
if
(
this
.
countc
==
1
){
}
else
{
const
audio
=
this
.
audioObj
[
lcard
[
"
audio_url
"
]];
audio
.
pause
();
audio
.
currentTime
=
0
;
}
this
.
playAudio
(
card
[
"
audio_url
"
]);
this
.
x
=
i
;
console
.
log
(
"
i-
"
+
i
);
this
.
playAudio
(
card
[
"
audio_url
"
]);
this
.
a
.
stop
();
this
.
w
.
stop
();
this
.
starttouzi
();
setTimeout
(()
=>
{
this
.
canTouch
=
true
;
},
1900
);
return
;
}
return
;
}
//点击图片正面的动作
for
(
let
i
=
0
;
i
<
this
.
cardArr
.
length
;
i
++
){
let
card
=
this
.
cardArr
[
i
];
let
cardBg
=
card
.
children
[
1
];
console
.
log
(
"
i
"
+
i
);
if
(
this
.
checkClickTarget
(
cardBg
)
&&
(
this
.
bs
[
i
]
==
1
)){
console
.
log
(
"
contc
"
+
this
.
countc
);
this
.
countc
++
;
let
lcard
;
lcard
=
this
.
cardArr
[
this
.
x
];
if
(
this
.
countc
==
1
){
}
else
{
const
audio
=
this
.
audioObj
[
lcard
[
"
audio_url
"
]];
audio
.
pause
();
audio
.
currentTime
=
0
;
}
}
countc
=
0
;
x
starttouzi
(){
this
.
count
++
;
//骰子转动,给一个随机数
this
.
canTouch
=
false
;
this
.
tAnimation
();
if
(
this
.
count
!=
1
){
hideItem
(
this
.
faguang
[
this
.
last
]);
}
if
(
this
.
count
==
6
){
this
.
count
=
0
;
setTimeout
(()
=>
{
//骰子消失
console
.
log
(
"
消失骰子数
"
+
this
.
t
);
// hideItem(this.tz);
this
.
tz
.
visible
=
false
;
//重新开始按钮
this
.
stn
.
visible
=
false
;
this
.
retn
.
visible
=
true
;
this
.
b
=
1
;
setTimeout
(()
=>
{
tweenChange
(
this
.
Btn
,
{
scaleX
:
1
,
scaleY
:
1
},
0.3
,
()
=>
{
});
},
180
);
}
this
.
playAudio
(
card
[
"
audio_url
"
]);
this
.
x
=
i
;
console
.
log
(
"
i-
"
+
i
);
this
.
playAudio
(
card
[
"
audio_url
"
]);
return
;
}
},
1800
);
}
}
}
b
btnIn1
(
item
){
this
.
playAudio
(
"
sm-in
"
);
tweenChange
(
item
,
{
y
:
200
},
.
3
);
}
btnOut
(
item
){
this
.
playAudio
(
"
sm-out
"
);
let
out
=
this
.
canvasWidth
+
200
*
this
.
mapScale
;
tweenChange
(
item
,
{
y
:
out
},
3
);
}
//开始游戏
startGame
(){
this
.
canTouch
=
false
;
this
.
playAudio
(
"
start
"
);
//生成随机数组
if
(
this
.
count
==
0
){
this
.
randomtz
();
}
//按钮消失
tweenChange
(
this
.
Btn
,
{
scaleX
:
1.2
,
scaleY
:
1.2
},
0.3
,
()
=>
{
});
setTimeout
(()
=>
{
tweenChange
(
this
.
Btn
,
{
scaleX
:
0
,
scaleY
:
0
},
0.3
,
()
=>
{
});
},
180
);
//卡片弹出来
setTimeout
(()
=>
{
this
.
initCard
();
},
180
);
//骰子掉下来
setTimeout
(()
=>
{
this
.
touzi
();
},
300
);
}
tz
t
;
randomt
touzi
(){
//骰子掉下来
this
.
btnIn1
(
this
.
tz
);
}
fancard
(){
this
.
overCard
(
this
.
cardArr
[
this
.
randomt
],()
=>
{
});
}
countc
=
0
;
x
starttouzi
(){
this
.
count
++
;
//骰子转动,给一个随机数
this
.
canTouch
=
false
;
this
.
tAnimation
();
if
(
this
.
count
!=
1
){
}
tAnimation
(){
this
.
randomt
=
this
.
newball
[
0
];
this
.
playAudio
(
"
touzi
"
);
this
.
canTouch
=
false
;
console
.
log
(
"
this.a
"
+
this
.
a
);
hideItem
(
this
.
faguang
[
this
.
last
]);
}
if
(
this
.
count
==
6
){
this
.
canTouch
=
false
;
this
.
count
=
0
;
setTimeout
(()
=>
{
//骰子消失
// hideItem(this.tz);
this
.
tz
.
visible
=
false
;
//重新开始按钮
this
.
stn
.
visible
=
false
;
this
.
retn
.
visible
=
true
;
this
.
b
=
1
;
setTimeout
(()
=>
{
tweenChange
(
this
.
Btn
,
{
scaleX
:
1
,
scaleY
:
1
},
0.3
,
()
=>
{
});
},
180
);
},
1300
);
}
console
.
log
(
this
.
t
[
this
.
randomt
]
+
"
kongmei22222222
"
);
const
animation
=
new
MyAnimation
();
for
(
let
j
=
0
;
j
<
2
;
j
++
){
for
(
let
i
=
0
;
i
<
6
;
i
++
){
const
imgobj
=
this
.
images
.
get
(
'
touzi
'
+
i
);
animation
.
addFrameByImg
(
imgobj
);
}
}
animation
.
delayPerUnit
=
0.09
;
//骰子旋转
animation
.
play
();
}
b
btnIn1
(
item
){
this
.
playAudio
(
"
sm-in
"
);
tweenChange
(
item
,
{
y
:
this
.
canvasHeight
-
100
*
this
.
mapScale
},
.
3
);
}
btnOut
(
item
){
this
.
playAudio
(
"
sm-out
"
);
let
out
=
this
.
canvasWidth
+
200
*
this
.
mapScale
;
tweenChange
(
item
,
{
y
:
out
},
3
);
}
//开始游戏
startGame
(){
this
.
canTouch
=
false
;
this
.
playAudio
(
"
start
"
);
//生成随机数组
if
(
this
.
count
==
0
){
this
.
randomtz
();
}
//按钮消失
tweenChange
(
this
.
Btn
,
{
scaleX
:
1.2
,
scaleY
:
1.2
},
0.3
,
()
=>
{
});
setTimeout
(()
=>
{
tweenChange
(
this
.
Btn
,
{
scaleX
:
0
,
scaleY
:
0
},
0.3
,
()
=>
{
});
},
180
);
//卡片弹出来
setTimeout
(()
=>
{
this
.
initCard
();
animation
.
playEnd
=
()
=>
{
if
(
this
.
data
.
sideA
==
1
)
{
//默认正面
this
.
bs
[
this
.
randomt
]
=
0
;
}
if
(
this
.
data
.
sideB
==
1
){
this
.
bs
[
this
.
randomt
]
=
1
;
}
animation
.
stop
();
console
.
log
(
"
---------
"
+
this
.
randomt
);
let
x
=
3
;
// this.t.init(this.images.get("t"+x));
this
.
t
.
init
(
this
.
images
.
get
(
"
t
"
+
(
this
.
randomt
+
1
)));
},
180
);
//骰子掉下来
setTimeout
(()
=>
{
this
.
touzi
();
},
300
);
}
alphaItem
(
this
.
faguang
[
this
.
randomt
],
1
);
this
.
last
=
this
.
randomt
;
this
.
overCard
(
this
.
cardArr
[
this
.
randomt
],()
=>
{
//发光特效
//this.cardArr[this.randomt].faguang.visible=true;
// this.cardArr[this.randomt].children[]
tz
t
;
randomt
touzi
(){
let
rect
=
this
.
cardArr
[
this
.
randomt
].
getBoundingBox
();
rect
.
x
=
this
.
cardArr
[
this
.
randomt
].
x
-
120
;
rect
.
y
=
this
.
cardArr
[
this
.
randomt
].
y
-
140
;
rect
.
width
=
250
;
rect
.
height
=
250
;
console
.
log
(
"
rect
"
+
rect
.
width
);
console
.
log
(
"
cardx
"
+
this
.
cardArr
[
this
.
randomt
].
x
);
console
.
log
(
"
cardy
"
+
this
.
cardArr
[
this
.
randomt
].
y
);
showBlingBling
(
this
.
images
.
get
(
'
ss
'
),
rect
,
this
.
bgLayer
,
this
.
mapScale
*
1.5
,
1
,
0.05
,
1.5
);
});
//骰子掉下来
this
.
btnIn1
(
this
.
tz
);
this
.
newball
.
splice
(
0
,
1
);
this
.
a
.
start
();
this
.
w
.
start
();
};
}
fancard
(){
this
.
overCard
(
this
.
cardArr
[
this
.
randomt
],()
=>
{
});
this
.
tz
.
addChild
(
animation
);
}
ss1
ss2
ss3
ss4
oldball
newball
randomtz
(){
this
.
oldball
=
[
0
,
1
,
2
,
3
,
4
,
5
];
this
.
oldball
=
randomSortByArr
(
this
.
oldball
);
this
.
newball
=
this
.
oldball
;
}
endPageArr
;
showPetalFlag
;
initCard
(){
this
.
randomItemCard
();
// this.cardArr = randomSortByArr(this.cardArr); //重新排序卡片组
this
.
initItemCard
();
//设定卡片的位置
//卡片恢复之前的状态
for
(
let
i
=
0
;
i
<
this
.
cardArr
.
length
;
i
++
){
let
card
=
this
.
cardArr
[
i
];
card
.
setScaleXY
(
this
.
mapScale
);
card
.
alpha
=
1
;
}
this
.
StartAnimation
(
this
.
cardArr
);
}
initItemCard
(){
const
picLength
=
this
.
cardArr
.
length
;
}
tAnimation
(){
this
.
randomt
=
this
.
newball
[
0
];
this
.
playAudio
(
"
touzi
"
);
const
top
=
(
120
)
*
this
.
mapScale
;
//第一排
const
top2
=
(
212
+
160
)
*
this
.
mapScale
;
//第二排
const
allWidth
=
((
picLength
/
2
)
*
280
+
(
picLength
/
2
-
1
)
*
80
)
*
this
.
mapScale
;
const
drawItem
=
(
index
)
=>
{
//设置卡片间距
let
itemBack
=
this
.
cardArr
[
index
];
itemBack
.
x
=
(
this
.
canvasWidth
-
allWidth
)
/
2
+
((
Math
.
floor
(
index
/
2
)
*
(
253
+
55
))
+
200
)
*
this
.
mapScale
;
if
(
index
%
2
==
0
){
itemBack
.
y
=
top
;
}
else
{
itemBack
.
y
=
top2
;
}
itemBack
.
setScaleXY
(
this
.
mapScale
);
this
.
renderArr
.
push
(
itemBack
);
};
const
drawItem2
=
(
index
)
=>
{
let
itemBack
=
this
.
cardArr
[
index
];
//itemBack.x = ((this.canvasWidth-allWidth)/2)*this.mapScale;
if
(
index
%
2
==
0
){
itemBack
.
x
=
top
*
2
+
100
;
}
else
{
itemBack
.
x
=
top2
*
2
-
170
;
}
itemBack
.
y
=
top
*
2
-
30
;
itemBack
.
setScaleXY
(
this
.
mapScale
);
this
.
renderArr
.
push
(
itemBack
);
};
if
(
picLength
==
2
){
for
(
let
i
=
0
;
i
<
picLength
;
i
++
){
drawItem2
(
i
);
}
}
else
{
for
(
let
i
=
0
;
i
<
picLength
;
i
++
){
drawItem
(
i
);
}
}
}
StartAnimation
(
cardArr
){
//卡片渐进显示
/*for(let i=0;i<cardArr.length;i++){
tweenChange(cardArr[i], {alpha: 1}, 0.3, ()=>{
setTimeout(() => {
this.playAudio("sm-back");
this.overCard(cardArr[i],()=>{
this.canTouch = true;
});
console
.
log
(
"
this.a
"
+
this
.
a
);
}, 1000);
});
}*/
for
(
let
i
=
0
;
i
<
cardArr
.
length
;
i
++
){
tweenChange
(
cardArr
[
i
],
{
scaleX
:
0
,
scaleY
:
0
},
0
,
()
=>
{
const
animation
=
new
MyAnimation
();
for
(
let
j
=
0
;
j
<
2
;
j
++
){
for
(
let
i
=
0
;
i
<
6
;
i
++
){
const
imgobj
=
this
.
images
.
get
(
'
touzi
'
+
i
);
animation
.
addFrameByImg
(
imgobj
);
}
}
animation
.
delayPerUnit
=
0.09
;
//骰子旋转
animation
.
play
();
animation
.
playEnd
=
()
=>
{
if
(
this
.
data
.
sideA
==
1
)
{
//默认正面
this
.
bs
[
this
.
randomt
]
=
0
;
}
if
(
this
.
data
.
sideB
==
1
){
this
.
bs
[
this
.
randomt
]
=
1
;
}
animation
.
stop
();
let
x
=
3
;
// this.t.init(this.images.get("t"+x));
this
.
t
.
init
(
this
.
images
.
get
(
"
t
"
+
(
this
.
randomt
+
1
)));
alphaItem
(
this
.
faguang
[
this
.
randomt
],
1
);
this
.
last
=
this
.
randomt
;
this
.
overCard
(
this
.
cardArr
[
this
.
randomt
],()
=>
{
//发光特效
//this.cardArr[this.randomt].faguang.visible=true;
// this.cardArr[this.randomt].children[]
let
rect
=
this
.
cardArr
[
this
.
randomt
].
getBoundingBox
();
rect
.
x
=
this
.
cardArr
[
this
.
randomt
].
x
-
120
;
rect
.
y
=
this
.
cardArr
[
this
.
randomt
].
y
-
140
;
rect
.
width
=
250
;
rect
.
height
=
250
;
showBlingBling
(
this
.
images
.
get
(
'
ss
'
),
rect
,
this
.
bgLayer
,
this
.
mapScale
*
1.5
,
1
,
0.05
,
1.5
);
});
setTimeout
(()
=>
{
tweenChange
(
cardArr
[
i
],
{
scaleX
:
0.5
,
scaleY
:
0.5
},
0.3
);
});
this
.
newball
.
splice
(
0
,
1
);
this
.
a
.
start
();
this
.
w
.
start
();
};
this
.
tz
.
addChild
(
animation
);
}
ss1
ss2
ss3
ss4
oldball
newball
randomtz
(){
this
.
oldball
=
[
0
,
1
,
2
,
3
,
4
,
5
];
this
.
oldball
=
randomSortByArr
(
this
.
oldball
);
this
.
newball
=
this
.
oldball
;
}
endPageArr
;
showPetalFlag
;
initCard
(){
this
.
randomItemCard
();
// this.cardArr = randomSortByArr(this.cardArr); //重新排序卡片组
this
.
initItemCard
();
//设定卡片的位置
},
1000
);
}
}
overCard
(
item
,
callback
?:
any
){
let
w
=
item
.
scaleX
;
this
.
playAudio
(
"
card
"
);
tweenChange
(
item
,
{
scaleX
:
0
},
0.3
,()
=>
{
item
.
children
[
2
].
visible
=
!
item
.
children
[
2
].
visible
;
tweenChange
(
item
,
{
scaleX
:
w
},
0.3
,()
=>
{
callback
&&
callback
();
});
});
}
q
front
=
[]
back
=
[]
bs
=
[];
faguang
=
[]
randomItemCard
(){
this
.
cardArr
=
[];
for
(
let
i
=
0
;
i
<
6
;
i
++
){
let
item
=
this
.
picArr
[
i
];
let
pic
=
new
MySprite
();
//初始化设置为隐藏
pic
.
alpha
=
1
;
pic
.
childDepandAlpha
=
true
;
//声明正反面的对象
this
.
back
[
i
]
=
new
MySprite
();
this
.
front
[
i
]
=
new
MySprite
();
this
.
faguang
[
i
]
=
new
MySprite
();
this
.
faguang
[
i
].
alpha
=
0
;
//卡片恢复之前的状态
for
(
let
i
=
0
;
i
<
this
.
cardArr
.
length
;
i
++
){
let
card
=
this
.
cardArr
[
i
];
card
.
setScaleXY
(
this
.
mapScale
);
card
.
alpha
=
1
;
}
this
.
StartAnimation
(
this
.
cardArr
);
}
initItemCard
(){
const
picLength
=
this
.
cardArr
.
length
;
const
top
=
(
120
)
*
this
.
mapScale
;
//卡片第一排距离头顶的距离
const
top2
=
(
212
+
160
)
*
this
.
mapScale
;
//卡片第二排距离头顶的距离
//设置索引
pic
[
"
index
"
]
=
i
;
this
.
faguang
[
i
].
init
(
this
.
images
.
get
(
"
发光
"
));
let
bgRect
=
new
ShapeRect
();
bgRect
.
setSize
(
390
,
390
);
bgRect
.
init
();
bgRect
.
fillColor
=
'
#ff83fa
'
;
this
.
front
[
i
].
addChild
(
bgRect
,
-
1
);
this
.
q
=
bgRect
;
const
allWidth
=
((
picLength
/
2
)
*
280
+
(
picLength
/
2
-
1
)
*
80
)
*
this
.
mapScale
;
//卡片总宽
const
drawItem
=
(
index
)
=>
{
//设置卡片间距
let
itemBack
=
this
.
cardArr
[
index
];
if
(
index
<
3
){
itemBack
.
y
=
top
;
itemBack
.
x
=
(
this
.
canvasWidth
-
allWidth
)
/
2
+
(((
index
)
*
(
253
+
55
))
+
200
)
*
this
.
mapScale
;
//剩余的宽加
}
else
{
itemBack
.
y
=
top2
;
itemBack
.
x
=
(
this
.
canvasWidth
-
allWidth
)
/
2
+
(((
index
-
3
)
*
(
253
+
55
))
+
200
)
*
this
.
mapScale
;
//剩余的宽加
}
itemBack
.
setScaleXY
(
this
.
mapScale
);
this
.
renderArr
.
push
(
itemBack
);
//把设置好的正反面变量放到卡片组里
if
(
this
.
data
.
sideA
==
1
){
//如果选择默认是正面,bs=0
for
(
let
i
=
0
;
i
<
this
.
picArr
.
length
;
i
++
){
this
.
bs
[
i
]
=
1
;
}
};
pic
.
addChild
(
this
.
back
[
i
]);
pic
.
addChild
(
this
.
front
[
i
]);
for
(
let
i
=
0
;
i
<
6
;
i
++
){
drawItem
(
i
);
}
}
StartAnimation
(
cardArr
){
//卡片渐进显示
/*for(let i=0;i<cardArr.length;i++){
tweenChange(cardArr[i], {alpha: 1}, 0.3, ()=>{
setTimeout(() => {
this.playAudio("sm-back");
this.overCard(cardArr[i],()=>{
this.canTouch = true;
});
}, 1000);
});
}*/
}
else
if
(
this
.
data
.
sideB
==
1
){
for
(
let
i
=
0
;
i
<
this
.
picArr
.
length
;
i
++
){
this
.
bs
[
i
]
=
0
;
}
pic
.
addChild
(
this
.
front
[
i
]);
pic
.
addChild
(
this
.
back
[
i
]);
for
(
let
i
=
0
;
i
<
cardArr
.
length
;
i
++
){
tweenChange
(
cardArr
[
i
],
{
scaleX
:
0
,
scaleY
:
0
},
0
,
()
=>
{
});
setTimeout
(()
=>
{
tweenChange
(
cardArr
[
i
],
{
scaleX
:
0.5
,
scaleY
:
0.5
},
0.3
);
},
1000
);
}
}
overCard
(
item
,
callback
?:
any
){
let
w
=
item
.
scaleX
;
this
.
playAudio
(
"
card
"
);
tweenChange
(
item
,
{
scaleX
:
0
},
0.3
,()
=>
{
item
.
children
[
2
].
visible
=
!
item
.
children
[
2
].
visible
;
tweenChange
(
item
,
{
scaleX
:
w
},
0.3
,()
=>
{
callback
&&
callback
();
});
});
}
q
front
=
[]
back
=
[]
bs
=
[];
faguang
=
[]
randomItemCard
(){
}
//音频路径做属性保存,方便点击卡片播放
if
(
item
.
audio_url
){
pic
[
"
audio_url
"
]
=
item
.
audio_url
;
console
.
log
(
item
.
audio_url
+
"
pic-audio
"
);
}
const
maxLen
=
400
;
if
(
item
.
pic_url
){
let
pic
=
new
MySprite
();
pic
.
init
(
this
.
images
.
get
(
item
.
pic_url
));
//如果是横图设置图片填充卡片正面的比例
if
(
pic
.
width
>
pic
.
height
){
pic
.
setScaleXY
(
getMinScale
(
pic
,
maxLen
));
pic
.
x
=
2
;
this
.
front
[
i
].
addChild
(
pic
);
}
//如果是竖图设置图片填充卡片正面的比例
if
(
pic
.
width
<=
pic
.
height
&&
(
pic
.
width
+
40
)
>=
pic
.
height
){
pic
.
setScaleXY
(
getMinScale
(
pic
,
maxLen
-
80
));
pic
.
x
=
0
;
pic
.
y
=-
3
;
}
//如果是正方图设置图片填充卡片正面的比例
if
(
pic
.
width
<=
pic
.
height
&&
(
pic
.
width
+
40
)
<
pic
.
height
){
pic
.
setScaleXY
(
getMinScale
(
pic
,
maxLen
-
60
));
pic
.
x
=-
5
;
pic
.
y
=-
6
;
}
this
.
front
[
i
].
addChild
(
pic
);
this
.
cardArr
=
[];
for
(
let
i
=
0
;
i
<
6
;
i
++
){
let
item
=
this
.
picArr
[
i
];
let
pic
=
new
MySprite
();
//初始化设置为隐藏
pic
.
alpha
=
1
;
pic
.
childDepandAlpha
=
true
;
//声明正反面的对象
this
.
back
[
i
]
=
new
MySprite
();
this
.
front
[
i
]
=
new
MySprite
();
this
.
faguang
[
i
]
=
new
MySprite
();
this
.
faguang
[
i
].
alpha
=
0
;
//设置索引
pic
[
"
index
"
]
=
i
;
this
.
faguang
[
i
].
init
(
this
.
images
.
get
(
"
发光
"
));
let
bgRect
=
new
ShapeRect
();
bgRect
.
setSize
(
390
,
390
);
bgRect
.
init
();
bgRect
.
fillColor
=
'
#ff83fa
'
;
this
.
front
[
i
].
addChild
(
bgRect
,
-
1
);
this
.
q
=
bgRect
;
//把设置好的正反面变量放到卡片组里
if
(
this
.
data
.
sideA
==
1
){
}
else
{
const
label
=
new
Label
();
label
.
text
=
item
.
title
;
label
.
fontName
=
'
BRLNSDB
'
;
label
.
fontColor
=
'
#ed3a33
'
;
label
.
fontSize
=
200
;
label
.
textAlign
=
'
center
'
;
//如果选择默认是正面,bs=0
for
(
let
i
=
0
;
i
<
this
.
picArr
.
length
;
i
++
){
this
.
bs
[
i
]
=
1
;
}
pic
.
addChild
(
this
.
back
[
i
]);
pic
.
addChild
(
this
.
front
[
i
]);
}
else
if
(
this
.
data
.
sideB
==
1
){
for
(
let
i
=
0
;
i
<
this
.
picArr
.
length
;
i
++
){
this
.
bs
[
i
]
=
0
;
}
pic
.
addChild
(
this
.
front
[
i
]);
pic
.
addChild
(
this
.
back
[
i
]);
}
//音频路径做属性保存,方便点击卡片播放
if
(
item
.
audio_url
){
pic
[
"
audio_url
"
]
=
item
.
audio_url
;
console
.
log
(
item
.
audio_url
+
"
pic-audio
"
);
}
const
maxLen
=
400
;
if
(
item
.
pic_url
){
let
pic
=
new
MySprite
();
pic
.
init
(
this
.
images
.
get
(
item
.
pic_url
));
//如果是横图设置图片填充卡片正面的比例
if
(
pic
.
width
>
pic
.
height
){
pic
.
setScaleXY
(
getMinScale
(
pic
,
maxLen
));
pic
.
x
=
2
;
this
.
front
[
i
].
addChild
(
pic
);
}
//如果是竖图设置图片填充卡片正面的比例
if
(
pic
.
width
<=
pic
.
height
&&
(
pic
.
width
+
40
)
>=
pic
.
height
){
pic
.
setScaleXY
(
getMinScale
(
pic
,
maxLen
-
80
));
pic
.
x
=
0
;
pic
.
y
=-
3
;
}
//如果是正方图设置图片填充卡片正面的比例
if
(
pic
.
width
<=
pic
.
height
&&
(
pic
.
width
+
40
)
<
pic
.
height
){
pic
.
setScaleXY
(
getMinScale
(
pic
,
maxLen
-
60
));
pic
.
x
=-
5
;
pic
.
y
=-
6
;
}
this
.
front
[
i
].
addChild
(
pic
);
}
else
{
const
label
=
new
Label
();
label
.
text
=
item
.
title
;
label
.
fontName
=
'
BRLNSDB
'
;
label
.
fontColor
=
'
#ed3a33
'
;
label
.
fontSize
=
200
;
label
.
textAlign
=
'
center
'
;
label
.
setMaxSize
((
bgRect
.
width
-
20
)
+
10
);
console
.
log
(
bgRect
.
width
-
20
+
"
卡片文字位置
"
);
this
.
front
[
i
].
addChild
(
label
);
}
this
.
front
[
i
].
addChild
(
this
.
faguang
[
i
],
-
1
);
this
.
back
[
i
].
addChild
(
this
.
faguang
[
i
],
-
1
);
this
.
cardArr
.
push
(
pic
);
this
.
cardArr
[
i
].
alpha
=
1
;
label
.
setMaxSize
((
bgRect
.
width
-
20
)
+
10
);
console
.
log
(
bgRect
.
width
-
20
+
"
卡片文字位置
"
);
this
.
front
[
i
].
addChild
(
label
);
}
this
.
front
[
i
].
addChild
(
this
.
faguang
[
i
],
-
1
);
this
.
back
[
i
].
addChild
(
this
.
faguang
[
i
],
-
1
);
this
.
cardArr
.
push
(
pic
);
this
.
cardArr
[
i
].
alpha
=
1
;
}
this
.
back
[
0
].
init
(
this
.
images
.
get
(
"
back0
"
));
this
.
back
[
4
].
init
(
this
.
images
.
get
(
"
back0
"
));
this
.
back
[
1
].
init
(
this
.
images
.
get
(
"
back1
"
));
this
.
back
[
5
].
init
(
this
.
images
.
get
(
"
back1
"
));
this
.
back
[
3
].
init
(
this
.
images
.
get
(
"
back2
"
));
this
.
back
[
2
].
init
(
this
.
images
.
get
(
"
back2
"
));
this
.
front
[
0
].
init
(
this
.
images
.
get
(
"
front0
"
));
this
.
front
[
4
].
init
(
this
.
images
.
get
(
"
front0
"
));
this
.
front
[
1
].
init
(
this
.
images
.
get
(
"
front1
"
));
this
.
front
[
5
].
init
(
this
.
images
.
get
(
"
front1
"
));
this
.
front
[
3
].
init
(
this
.
images
.
get
(
"
front2
"
));
this
.
front
[
2
].
init
(
this
.
images
.
get
(
"
front2
"
));
}
initBg
()
{
this
.
bgLayer
=
new
MySprite
();
this
.
renderArr
.
push
(
this
.
bgLayer
);
const
bg
=
new
ShapeRect
();
bg
.
fillColor
=
'
#75d100
'
;
bg
.
setSize
(
this
.
canvasWidth
,
this
.
canvasHeight
);
this
.
renderArr
.
push
(
bg
);
this
.
bg
=
bg
;
}
this
.
back
[
0
].
init
(
this
.
images
.
get
(
"
back0
"
));
this
.
back
[
4
].
init
(
this
.
images
.
get
(
"
back0
"
));
this
.
back
[
1
].
init
(
this
.
images
.
get
(
"
back1
"
));
this
.
back
[
5
].
init
(
this
.
images
.
get
(
"
back1
"
));
this
.
back
[
3
].
init
(
this
.
images
.
get
(
"
back2
"
));
this
.
back
[
2
].
init
(
this
.
images
.
get
(
"
back2
"
));
this
.
front
[
0
].
init
(
this
.
images
.
get
(
"
front0
"
));
this
.
front
[
4
].
init
(
this
.
images
.
get
(
"
front0
"
));
this
.
front
[
1
].
init
(
this
.
images
.
get
(
"
front1
"
));
this
.
front
[
5
].
init
(
this
.
images
.
get
(
"
front1
"
));
this
.
front
[
3
].
init
(
this
.
images
.
get
(
"
front2
"
));
this
.
front
[
2
].
init
(
this
.
images
.
get
(
"
front2
"
));
//把图片填充入背景,全覆盖
this
.
startBorder
=
new
MySprite
();
this
.
startBorder
.
init
(
this
.
images
.
get
(
'
BG
'
));
this
.
startBorder
.
x
=
this
.
canvasWidth
/
2
;
this
.
startBorder
.
y
=
this
.
canvasHeight
/
2
;
const
sx
=
this
.
canvasWidth
/
this
.
startBorder
.
width
;
const
sy
=
this
.
canvasHeight
/
this
.
startBorder
.
height
;
const
s
=
Math
.
max
(
sx
,
sy
);
console
.
log
(
s
+
"
s
"
);
this
.
startBorder
.
setScaleXY
(
s
);
this
.
renderArr
.
push
(
this
.
startBorder
);
}
mapMove
(
event
)
{
}
...
...
@@ -1350,4 +1364,4 @@ faguang=[]
}
}
\ 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