Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
Lwd
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
Lwd
Commits
a0fd46f2
Commit
a0fd46f2
authored
Mar 30, 2021
by
Lwd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aaaa
parent
8acdd228
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
748 additions
and
446 deletions
+748
-446
Game.fire
play/assets/tmpGame/scene/Game.fire
+534
-313
view.js
play/assets/tmpGame/script/common/view.js
+128
-125
game.js
play/assets/tmpGame/script/game/game.js
+3
-3
result.js
play/assets/tmpGame/script/game/result.js
+47
-5
frame_dragon.png
play/assets/tmpGame/textures/frame_dragon.png
+0
-0
frame_dragon.png.meta
play/assets/tmpGame/textures/frame_dragon.png.meta
+36
-0
No files found.
play/assets/tmpGame/scene/Game.fire
View file @
a0fd46f2
This diff is collapsed.
Click to expand it.
play/assets/tmpGame/script/common/view.js
View file @
a0fd46f2
...
@@ -2,139 +2,142 @@
...
@@ -2,139 +2,142 @@
* 适配
* 适配
*/
*/
cc
.
Class
({
cc
.
Class
({
extends
:
cc
.
Component
,
extends
:
cc
.
Component
,
properties
:
{
properties
:
{
UIMax
:
{
UIMax
:
{
default
:
[],
default
:
[],
type
:
cc
.
Node
,
type
:
cc
.
Node
,
displayName
:
"
等比放大
"
displayName
:
"
等比放大
"
},
},
topUI
:
{
topUI
:
{
default
:
[],
default
:
[],
type
:
cc
.
Widget
,
type
:
cc
.
Widget
,
},
},
canvasView
:
{
default
:
null
,
type
:
cc
.
Canvas
,
displayName
:
"
根节点
"
},
isCanvas
:
{
default
:
false
,
}
},
onLoad
:
function
()
{
//开启适配
canvasView
:
{
this
.
widgetList
=
[];
default
:
null
,
this
.
scheduleOnce
(
function
()
{
type
:
cc
.
Canvas
,
if
(
!
this
.
isCanvas
)
{
displayName
:
"
根节点
"
this
.
init
();
},
}
else
{
isCanvas
:
{
var
canvaSize
=
this
.
findCanvas
();
default
:
false
,
var
w
=
(
canvaSize
.
width
)
/
720
;
}
var
h
=
(
canvaSize
.
height
)
/
1280
;
},
this
.
MaxSize
=
w
/
h
>
1
?
w
/
h
:
h
/
w
;
this
.
setUIMax
(
this
.
MaxSize
);
this
.
settopUI
(
this
.
MaxSize
);
var
scene
=
cc
.
director
.
getScene
();
var
list
=
scene
.
getComponentsInChildren
(
cc
.
Widget
)
onLoad
:
function
()
{
//开启适配
for
(
var
i
in
list
)
{
this
.
widgetList
=
[];
list
[
i
].
updateAlignment
();
this
.
scheduleOnce
(
function
()
{
}
if
(
!
this
.
isCanvas
)
{
}
this
.
init
();
},
0
);
}
else
{
this
.
MaxSize
=
1
;
var
canvaSize
=
this
.
findCanvas
();
var
w
=
(
canvaSize
.
width
)
/
720
;
var
h
=
(
canvaSize
.
height
)
/
1280
;
this
.
MaxSize
=
w
/
h
>
1
?
w
/
h
:
h
/
w
;
// if (window.addEventListener) {
this
.
setUIMax
(
this
.
MaxSize
);
// window.addEventListener('resize', scaleEventCallBack, false)
this
.
settopUI
(
this
.
MaxSize
);
// } else if (window.attachEvent) {
var
scene
=
cc
.
director
.
getScene
();
// window.attachEvent('resize', scaleEventCallBack, false)
// };
// g.event_mgr.reg("adjustUI", () => {
var
list
=
scene
.
getComponentsInChildren
(
cc
.
Widget
)
// this.init();
for
(
var
i
in
list
)
{
// });
list
[
i
].
updateAlignment
();
},
}
init
:
function
()
{
}
var
canvaSize
=
this
.
findCanvas
();
},
0
);
var
diff
=
canvaSize
.
width
/
canvaSize
.
height
;
this
.
MaxSize
=
1
;
var
bili
=
750
/
1334
;
// if (window.addEventListener) {
if
(
diff
>
bili
)
{
// window.addEventListener('resize', scaleEventCallBack, false)
this
.
canvasView
.
fitWidth
=
false
;
// } else if (window.attachEvent) {
this
.
canvasView
.
fitHeight
=
true
;
// window.attachEvent('resize', scaleEventCallBack, false)
}
else
if
(
diff
<
bili
)
{
// };
this
.
canvasView
.
fitWidth
=
true
;
this
.
canvasView
.
fitHeight
=
false
;
}
else
{
this
.
canvasView
.
fitWidth
=
true
;
this
.
canvasView
.
fitHeight
=
true
;
}
var
w
=
(
canvaSize
.
width
)
/
750
;
var
h
=
(
canvaSize
.
height
)
/
1334
;
this
.
MaxSize
=
w
/
h
>
1
?
w
/
h
:
h
/
w
;
g
.
data_mgr
.
MaxSize
=
this
.
MaxSize
;
this
.
setUIMax
(
this
.
MaxSize
);
this
.
settopUI
(
this
.
MaxSize
);
var
scene
=
cc
.
director
.
getScene
();
var
list
=
scene
.
getComponentsInChildren
(
cc
.
Widget
)
for
(
var
i
in
list
)
{
list
[
i
].
updateAlignment
();
}
},
// //屏幕缩放事件
// g.event_mgr.reg("adjustUI", () => {
// scaleEventCallBack: function () {
// this.init();
// //setTimeout(function () {
// });
// g.log("屏幕缩放");
},
// g.event_mgr.send("adjustUI");
init
:
function
()
{
// //}, 500); //延迟0.5秒
var
canvaSize
=
this
.
findCanvas
();
// },
var
diff
=
canvaSize
.
width
/
canvaSize
.
height
;
var
bili
=
750
/
1334
;
if
(
diff
>
bili
)
{
this
.
canvasView
.
fitWidth
=
false
;
this
.
canvasView
.
fitHeight
=
true
;
}
else
if
(
diff
<
bili
)
{
this
.
canvasView
.
fitWidth
=
true
;
this
.
canvasView
.
fitHeight
=
false
;
}
else
{
this
.
canvasView
.
fitWidth
=
true
;
this
.
canvasView
.
fitHeight
=
true
;
}
var
w
=
(
canvaSize
.
width
)
/
750
;
var
h
=
(
canvaSize
.
height
)
/
1334
;
this
.
MaxSize
=
w
/
h
>
1
?
w
/
h
:
h
/
w
;
onDestroy
:
function
()
{
g
.
data_mgr
.
MaxSize
=
this
.
MaxSize
;
this
.
setUIMax
(
this
.
MaxSize
);
this
.
settopUI
(
this
.
MaxSize
);
var
scene
=
cc
.
director
.
getScene
();
var
list
=
scene
.
getComponentsInChildren
(
cc
.
Widget
)
for
(
var
i
in
list
)
{
list
[
i
].
updateAlignment
();
}
},
},
settopUI
:
function
(
s
)
{
if
(
!
g
.
data_mgr
.
phoneInfo
)
{
return
;
}
var
top
=
g
.
data_mgr
.
phoneInfo
;
top
=
top
*
s
;
for
(
var
i
in
this
.
topUI
)
{
if
(
this
.
topUI
[
i
].
perTop
==
undefined
)
{
this
.
topUI
[
i
].
perTop
=
this
.
topUI
[
i
].
top
;
}
else
{
// //屏幕缩放事件
this
.
topUI
[
i
].
top
=
this
.
topUI
[
i
].
perTop
;
// scaleEventCallBack: function () {
}
// //setTimeout(function () {
this
.
topUI
[
i
].
top
+=
top
;
// g.log("屏幕缩放");
console
.
log
(
this
.
topUI
[
i
].
top
);
// g.event_mgr.send("adjustUI");
}
// //}, 500); //延迟0.5秒
},
// },
setUIMax
:
function
(
size
)
{
for
(
var
i
in
this
.
UIMax
)
{
if
(
this
.
UIMax
[
i
].
perScale
==
undefined
)
{
this
.
UIMax
[
i
].
perScale
=
this
.
UIMax
[
i
].
scaleX
;
}
else
{
onDestroy
:
function
()
{
this
.
UIMax
[
i
].
scaleX
=
this
.
UIMax
[
i
].
perScale
;
this
.
UIMax
[
i
].
scaleY
=
this
.
UIMax
[
i
].
perScale
;
},
}
settopUI
:
function
(
s
)
{
this
.
UIMax
[
i
].
scaleX
*=
size
;
if
(
!
g
.
data_mgr
.
phoneInfo
)
{
this
.
UIMax
[
i
].
scaleY
*=
size
;
return
;
}
}
},
var
top
=
g
.
data_mgr
.
phoneInfo
;
findCanvas
:
function
()
{
top
=
top
*
s
;
if
(
cc
.
sys
.
isNative
)
{
for
(
var
i
in
this
.
topUI
)
{
return
{
if
(
this
.
topUI
[
i
].
perTop
==
undefined
)
{
width
:
cc
.
view
.
getFrameSize
().
width
,
this
.
topUI
[
i
].
perTop
=
this
.
topUI
[
i
].
top
;
height
:
cc
.
view
.
getFrameSize
().
height
};
}
else
{
}
else
{
this
.
topUI
[
i
].
top
=
this
.
topUI
[
i
].
perTop
;
return
{
}
width
:
cc
.
game
.
canvas
.
clientWidth
,
this
.
topUI
[
i
].
top
+=
top
;
height
:
cc
.
game
.
canvas
.
clientHeight
console
.
log
(
this
.
topUI
[
i
].
top
);
};
}
}
},
}
setUIMax
:
function
(
size
)
{
for
(
var
i
in
this
.
UIMax
)
{
if
(
this
.
UIMax
[
i
].
perScale
==
undefined
)
{
this
.
UIMax
[
i
].
perScale
=
this
.
UIMax
[
i
].
scaleX
;
}
else
{
this
.
UIMax
[
i
].
scaleX
=
this
.
UIMax
[
i
].
perScale
;
this
.
UIMax
[
i
].
scaleY
=
this
.
UIMax
[
i
].
perScale
;
}
this
.
UIMax
[
i
].
scaleX
*=
size
;
this
.
UIMax
[
i
].
scaleY
*=
size
;
}
},
findCanvas
:
function
()
{
if
(
cc
.
sys
.
isNative
)
{
return
{
width
:
cc
.
view
.
getFrameSize
().
width
,
height
:
cc
.
view
.
getFrameSize
().
height
};
}
else
{
return
{
width
:
cc
.
game
.
canvas
.
clientWidth
,
height
:
cc
.
game
.
canvas
.
clientHeight
};
}
}
});
});
play/assets/tmpGame/script/game/game.js
View file @
a0fd46f2
...
@@ -84,7 +84,6 @@ var game = cc.Class({
...
@@ -84,7 +84,6 @@ var game = cc.Class({
console
.
log
(
"
游戏开始:
"
+
g
.
data_mgr
);
console
.
log
(
"
游戏开始:
"
+
g
.
data_mgr
);
//播放一个上面的音乐
//播放一个上面的音乐
this
.
setAudioInfo
(
1
);
this
.
setAudioInfo
(
1
);
this
.
PlayAudio
();
},
},
//获得随机播放的音乐并播放
//获得随机播放的音乐并播放
...
@@ -95,6 +94,7 @@ var game = cc.Class({
...
@@ -95,6 +94,7 @@ var game = cc.Class({
//设置播放信息
//设置播放信息
g
.
data_mgr
.
playId
=
num
;
g
.
data_mgr
.
playId
=
num
;
g
.
data_mgr
.
playType
=
type
;
g
.
data_mgr
.
playType
=
type
;
this
.
PlayAudio
();
},
},
//重新播放音乐
//重新播放音乐
...
@@ -121,6 +121,8 @@ var game = cc.Class({
...
@@ -121,6 +121,8 @@ var game = cc.Class({
g
.
data_mgr
.
addPreloadAudio
();
g
.
data_mgr
.
addPreloadAudio
();
g
.
data_mgr
.
addPreloadAnima
();
g
.
data_mgr
.
addPreloadAnima
();
g
.
result
.
inst
.
End
=
true
;
//初始化界面
//初始化界面
this
.
UpdataUi
();
this
.
UpdataUi
();
...
@@ -130,8 +132,6 @@ var game = cc.Class({
...
@@ -130,8 +132,6 @@ var game = cc.Class({
//游戏开始
//游戏开始
g
.
game
.
inst
.
gameStart
();
g
.
game
.
inst
.
gameStart
();
//清除线
//清除线
this
.
clearLine
();
this
.
clearLine
();
},
},
...
...
play/assets/tmpGame/script/game/result.js
View file @
a0fd46f2
/**
/**
* result
* result
*/
*/
const
Color_texts
=
[
'
#BE1AC1
'
,
'
#2
4C11A
'
,
'
#1A1DC1
'
,
'
#9F5307
'
];
const
Color_texts
=
[
'
#BE1AC1
'
,
'
#2
E6EEE
'
,
'
#1A1DC1
'
,
'
#770060
'
];
var
result
=
cc
.
Class
({
var
result
=
cc
.
Class
({
extends
:
cc
.
Component
,
extends
:
cc
.
Component
,
...
@@ -86,7 +86,37 @@ var result = cc.Class({
...
@@ -86,7 +86,37 @@ var result = cc.Class({
// 初始化文本
// 初始化文本
initRichText
(
text
)
{
initRichText
(
text
)
{
this
.
lb_tips
.
string
=
text
;
//this.lb_tips.string = text;
// text = 'I am flying';
this
.
layoutText
.
removeAllChildren
();
if
(
!
text
)
{
return
;
}
text
=
text
.
replace
(
/ /g
,
"
|
"
);
let
arr
=
text
.
split
(
'
|
'
);
if
(
arr
.
length
<=
0
)
{
return
;
}
this
.
layoutText
.
active
=
true
;
this
.
lb_tips
.
string
=
arr
[
0
];
this
.
lb_tips
.
_forceUpdateRenderData
(
true
)
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
+
1
]
==
'
'
)
{
continue
;
}
let
node
=
cc
.
instantiate
(
this
.
lb_tips
.
node
);
let
label
=
node
.
getComponent
(
cc
.
Label
);
label
.
string
=
arr
[
i
];
node
.
parent
=
this
.
layoutText
;
label
.
_forceUpdateRenderData
(
true
);
}
this
.
layoutText
.
getComponent
(
cc
.
Layout
).
updateLayout
();
let
width
=
this
.
layoutText
.
width
;
if
(
width
>
1000
)
{
let
scale
=
1000
/
width
;
this
.
layoutText
.
scale
=
scale
;
}
},
},
//设置图片
//设置图片
...
@@ -113,7 +143,9 @@ var result = cc.Class({
...
@@ -113,7 +143,9 @@ var result = cc.Class({
},
},
playAudio
()
{
playAudio
()
{
cc
.
assetManager
.
loadRemote
(
this
.
itemInfo
.
group_audio_url
,
null
,
(
err
,
clip
)
=>
{
// this.itemInfo.group_audio_url
var
test
=
"
http://staging-teach.cdn.ireadabc.com/495324991838775e49e3ca6593d432c9.mp3
"
cc
.
assetManager
.
loadRemote
(
test
,
null
,
(
err
,
clip
)
=>
{
this
.
audioID
=
cc
.
audioEngine
.
play
(
clip
,
false
,
1
);
this
.
audioID
=
cc
.
audioEngine
.
play
(
clip
,
false
,
1
);
this
.
audioDuration
=
cc
.
audioEngine
.
getDuration
(
this
.
audioID
);
this
.
audioDuration
=
cc
.
audioEngine
.
getDuration
(
this
.
audioID
);
this
.
textDuration
=
this
.
audioDuration
/
this
.
layoutText
.
childrenCount
;
this
.
textDuration
=
this
.
audioDuration
/
this
.
layoutText
.
childrenCount
;
...
@@ -125,7 +157,7 @@ var result = cc.Class({
...
@@ -125,7 +157,7 @@ var result = cc.Class({
cc
.
audioEngine
.
stop
(
this
.
audioID
);
cc
.
audioEngine
.
stop
(
this
.
audioID
);
this
.
unschedule
(
this
.
chengeTextColor
);
this
.
unschedule
(
this
.
chengeTextColor
);
this
.
isPlaying
=
false
;
this
.
isPlaying
=
false
;
this
.
stopSpine
();
//
this.stopSpine();
},
},
chengeTextColor
()
{
chengeTextColor
()
{
...
@@ -139,17 +171,27 @@ var result = cc.Class({
...
@@ -139,17 +171,27 @@ var result = cc.Class({
},
},
clearTextColor
()
{
clearTextColor
()
{
for
(
let
i
=
0
;
i
<
this
.
layoutText
.
children
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
layoutText
.
children
.
length
;
i
++
)
{
this
.
layoutText
.
children
[
i
].
color
=
new
cc
.
Color
().
fromHEX
(
Color_texts
[
3
]);
this
.
layoutText
.
children
[
i
].
color
=
new
cc
.
Color
().
fromHEX
(
Color_texts
[
1
]);
}
}
},
},
onBtnText
()
{
this
.
clearTextColor
();
this
.
stopAudio
();
this
.
playAudio
();
},
//点击关闭
//点击关闭
onBtnClose
:
function
()
{
onBtnClose
:
function
()
{
this
.
node
.
active
=
false
;
this
.
node
.
active
=
false
;
//如果播放列表少于1则显示
//如果播放列表少于1则显示
if
(
this
.
End
==
false
)
{
return
;
}
if
(
g
.
data_mgr
.
temPlayAudio
.
length
<
1
)
{
if
(
g
.
data_mgr
.
temPlayAudio
.
length
<
1
)
{
//显示结算撒花
//显示结算撒花
g
.
game
.
inst
.
showResult
();
g
.
game
.
inst
.
showResult
();
this
.
End
=
false
;
}
else
{
}
else
{
//重新随机一组数据
//重新随机一组数据
g
.
game
.
inst
.
setAudioInfo
(
1
);
g
.
game
.
inst
.
setAudioInfo
(
1
);
...
...
play/assets/tmpGame/textures/frame_dragon.png
0 → 100644
View file @
a0fd46f2
292 KB
play/assets/tmpGame/textures/frame_dragon.png.meta
0 → 100644
View file @
a0fd46f2
{
"ver": "2.3.5",
"uuid": "b1526667-de09-4475-a793-de7e9b63c68d",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 852,
"height": 516,
"platformSettings": {},
"subMetas": {
"frame_dragon": {
"ver": "1.0.4",
"uuid": "8c658fc0-c1e4-4993-bce4-b5cce324b69b",
"rawTextureUuid": "b1526667-de09-4475-a793-de7e9b63c68d",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 852,
"height": 516,
"rawWidth": 852,
"rawHeight": 516,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ 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