Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cc_mz_003
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
cc_mz_003
Commits
962ed42f
Commit
962ed42f
authored
Dec 08, 2020
by
Li MingZhe
Browse files
Options
Browse Files
Download
Plain Diff
feat: 背景色更改
parents
f7228ce8
9e19eb64
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
24 deletions
+27
-24
scene.js
play/assets/mz_003/script/scene.js
+27
-24
No files found.
play/assets/mz_003/script/scene.js
View file @
962ed42f
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
// Learn life-cycle callbacks:
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import
{
localPosTolocalPos
}
from
"
./util
"
;
import
{
localPosTolocalPos
}
from
"
./util
"
;
cc
.
Class
({
cc
.
Class
({
extends
:
cc
.
Component
,
extends
:
cc
.
Component
,
...
@@ -75,6 +75,7 @@ cc.Class({
...
@@ -75,6 +75,7 @@ cc.Class({
},
},
start
()
{
start
()
{
cc
.
debug
.
setDisplayStats
(
false
);
let
getData
=
this
.
getData
.
bind
(
this
);
let
getData
=
this
.
getData
.
bind
(
this
);
if
(
window
&&
window
.
courseware
)
{
if
(
window
&&
window
.
courseware
)
{
// console.log('has window');
// console.log('has window');
...
@@ -85,6 +86,8 @@ cc.Class({
...
@@ -85,6 +86,8 @@ cc.Class({
this
.
data
=
data
||
this
.
getDefaultData
();
this
.
data
=
data
||
this
.
getDefaultData
();
this
.
preloadItem
()
this
.
preloadItem
()
})
})
console
.
log
(
'
cc.sys.capabilities["touches"] =
'
,
cc
.
sys
.
capabilities
[
"
touches
"
]);
},
},
...
@@ -180,14 +183,14 @@ cc.Class({
...
@@ -180,14 +183,14 @@ cc.Class({
addPreloadImage
()
{
addPreloadImage
()
{
if
(
this
.
data
.
bgItem
)
{
if
(
this
.
data
.
bgItem
)
{
this
.
_imageResList
.
push
({
url
:
this
.
data
.
bgItem
.
url
});
this
.
_imageResList
.
push
({
url
:
this
.
data
.
bgItem
.
url
});
}
}
if
(
!
this
.
data
.
hotZoneItemArr
)
{
if
(
!
this
.
data
.
hotZoneItemArr
)
{
return
;
return
;
}
}
this
.
data
.
hotZoneItemArr
.
forEach
((
item
)
=>
{
this
.
data
.
hotZoneItemArr
.
forEach
((
item
)
=>
{
if
(
item
.
gIdx
==
'
0
'
&&
item
.
pic_url
)
{
if
(
item
.
gIdx
==
'
0
'
&&
item
.
pic_url
)
{
this
.
_imageResList
.
push
({
url
:
item
.
pic_url
});
this
.
_imageResList
.
push
({
url
:
item
.
pic_url
});
}
}
})
})
...
@@ -199,7 +202,7 @@ cc.Class({
...
@@ -199,7 +202,7 @@ cc.Class({
return
;
return
;
}
}
this
.
data
.
hotZoneItemArr
.
forEach
((
item
)
=>
{
this
.
data
.
hotZoneItemArr
.
forEach
((
item
)
=>
{
this
.
_audioResList
.
push
({
url
:
item
.
audio_url
});
this
.
_audioResList
.
push
({
url
:
item
.
audio_url
});
})
})
},
},
...
@@ -209,9 +212,9 @@ cc.Class({
...
@@ -209,9 +212,9 @@ cc.Class({
}
}
this
.
data
.
hotZoneItemArr
.
forEach
((
item
)
=>
{
this
.
data
.
hotZoneItemArr
.
forEach
((
item
)
=>
{
if
(
item
.
gIdx
==
'
0
'
&&
item
.
skeJsonData
)
{
if
(
item
.
gIdx
==
'
0
'
&&
item
.
skeJsonData
)
{
this
.
_animaResList
.
push
({
url
:
item
.
skeJsonData
.
url
});
this
.
_animaResList
.
push
({
url
:
item
.
skeJsonData
.
url
});
this
.
_animaResList
.
push
({
url
:
item
.
texJsonData
.
url
});
this
.
_animaResList
.
push
({
url
:
item
.
texJsonData
.
url
});
this
.
_animaResList
.
push
({
url
:
item
.
texPngData
.
url
});
this
.
_animaResList
.
push
({
url
:
item
.
texPngData
.
url
});
}
}
})
})
...
@@ -458,8 +461,8 @@ cc.Class({
...
@@ -458,8 +461,8 @@ cc.Class({
const
bgNode
=
cc
.
find
(
'
Canvas/bg
'
);
const
bgNode
=
cc
.
find
(
'
Canvas/bg
'
);
// const sx = cc.winSize.width / bgNode.width;
// const sx = cc.winSize.width / bgNode.width;
// const sy = cc.winSize.height / bgNode.height;
// const sy = cc.winSize.height / bgNode.height;
sx
=
frameSize
.
width
/
bgNode
.
width
;
sx
=
frameSize
.
width
/
bgNode
.
width
;
sy
=
frameSize
.
height
/
bgNode
.
height
;
sy
=
frameSize
.
height
/
bgNode
.
height
;
bgNode
.
scale
=
Math
.
max
(
sx
,
sy
)
*
s
;
bgNode
.
scale
=
Math
.
max
(
sx
,
sy
)
*
s
;
bgNode
.
anchorX
=
1
;
bgNode
.
anchorX
=
1
;
bgNode
.
anchorY
=
0
;
bgNode
.
anchorY
=
0
;
...
@@ -504,7 +507,7 @@ cc.Class({
...
@@ -504,7 +507,7 @@ cc.Class({
return
;
return
;
}
}
cc
.
loader
.
load
({
url
:
this
.
data
.
bgItem
.
url
},
(
err
,
img
)
=>
{
cc
.
loader
.
load
({
url
:
this
.
data
.
bgItem
.
url
},
(
err
,
img
)
=>
{
this
.
addMask
(
this
.
hotZoneBg
);
this
.
addMask
(
this
.
hotZoneBg
);
...
@@ -535,8 +538,8 @@ cc.Class({
...
@@ -535,8 +538,8 @@ cc.Class({
bgBottom
.
scale
=
mapS
*
this
.
_cocosScale
;
bgBottom
.
scale
=
mapS
*
this
.
_cocosScale
;
// subNum = bgBottom.height;
// subNum = bgBottom.height;
sx
=
frameSize
.
width
*
this
.
_cocosScale
/
img
.
width
;
sx
=
frameSize
.
width
*
this
.
_cocosScale
/
img
.
width
;
sy
=
(
frameSize
.
height
*
this
.
_cocosScale
-
subNum
*
mapS
*
this
.
_cocosScale
)
/
img
.
height
;
sy
=
(
frameSize
.
height
*
this
.
_cocosScale
-
subNum
*
mapS
*
this
.
_cocosScale
)
/
img
.
height
;
const
sprNode
=
new
cc
.
Node
();
const
sprNode
=
new
cc
.
Node
();
...
@@ -551,7 +554,7 @@ cc.Class({
...
@@ -551,7 +554,7 @@ cc.Class({
this
.
hotZoneBg
.
scale
=
Math
.
min
(
sx
,
sy
);
this
.
hotZoneBg
.
scale
=
Math
.
min
(
sx
,
sy
);
// this.hotZoneBg.y = -frameSize.height / 2 * this._cocosScale + this.hotZoneBg.height / 2 * this.hotZoneBg.scaleY + (subNum * mapS * this._cocosScale);
// this.hotZoneBg.y = -frameSize.height / 2 * this._cocosScale + this.hotZoneBg.height / 2 * this.hotZoneBg.scaleY + (subNum * mapS * this._cocosScale);
this
.
hotZoneBg
.
y
=
frameSize
.
height
/
2
*
this
.
_cocosScale
-
this
.
hotZoneBg
.
height
/
2
*
this
.
hotZoneBg
.
scaleY
;
this
.
hotZoneBg
.
y
=
frameSize
.
height
/
2
*
this
.
_cocosScale
-
this
.
hotZoneBg
.
height
/
2
*
this
.
hotZoneBg
.
scaleY
;
// this.hotZoneBg.opacity = 20;
// this.hotZoneBg.opacity = 20;
...
@@ -584,7 +587,7 @@ cc.Class({
...
@@ -584,7 +587,7 @@ cc.Class({
// if (item.gIdx == '0') {
// if (item.gIdx == '0') {
// this.setOneAnima(item);
// this.setOneAnima(item);
// } else {
// } else {
this
.
setOneCirclePoint
(
item
);
this
.
setOneCirclePoint
(
item
);
// }
// }
this
.
setOnePic
(
item
);
this
.
setOnePic
(
item
);
...
@@ -684,9 +687,9 @@ cc.Class({
...
@@ -684,9 +687,9 @@ cc.Class({
const
atlas
=
data
.
texJsonData
.
url
//"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json";
const
atlas
=
data
.
texJsonData
.
url
//"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json";
cc
.
loader
.
load
(
image
,
(
error
,
texture
)
=>
{
cc
.
loader
.
load
(
image
,
(
error
,
texture
)
=>
{
cc
.
loader
.
load
({
url
:
atlas
,
type
:
'
txt
'
},
(
error
,
atlasJson
)
=>
{
cc
.
loader
.
load
({
url
:
atlas
,
type
:
'
txt
'
},
(
error
,
atlasJson
)
=>
{
cc
.
loader
.
load
({
url
:
ske
,
type
:
'
txt
'
},
(
error
,
dragonBonesJson
)
=>
{
cc
.
loader
.
load
({
url
:
ske
,
type
:
'
txt
'
},
(
error
,
dragonBonesJson
)
=>
{
const
atlas
=
new
dragonBones
.
DragonBonesAtlasAsset
();
const
atlas
=
new
dragonBones
.
DragonBonesAtlasAsset
();
atlas
.
atlasJson
=
atlasJson
;
atlas
.
atlasJson
=
atlasJson
;
...
@@ -751,7 +754,7 @@ cc.Class({
...
@@ -751,7 +754,7 @@ cc.Class({
picNode
.
data
=
data
;
picNode
.
data
=
data
;
this
.
hotZoneBg
.
addChild
(
picNode
);
this
.
hotZoneBg
.
addChild
(
picNode
);
cc
.
loader
.
load
({
url
:
data
.
pic_url
},
(
err
,
img
)
=>
{
cc
.
loader
.
load
({
url
:
data
.
pic_url
},
(
err
,
img
)
=>
{
const
spr
=
picNode
.
addComponent
(
cc
.
Sprite
);
const
spr
=
picNode
.
addComponent
(
cc
.
Sprite
);
spr
.
spriteFrame
=
new
cc
.
SpriteFrame
(
img
)
spr
.
spriteFrame
=
new
cc
.
SpriteFrame
(
img
)
...
@@ -831,9 +834,9 @@ cc.Class({
...
@@ -831,9 +834,9 @@ cc.Class({
const
atlas
=
data
.
texJsonData
.
url
//"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json";
const
atlas
=
data
.
texJsonData
.
url
//"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json";
cc
.
loader
.
load
(
image
,
(
error
,
texture
)
=>
{
cc
.
loader
.
load
(
image
,
(
error
,
texture
)
=>
{
cc
.
loader
.
load
({
url
:
atlas
,
type
:
'
txt
'
},
(
error
,
atlasJson
)
=>
{
cc
.
loader
.
load
({
url
:
atlas
,
type
:
'
txt
'
},
(
error
,
atlasJson
)
=>
{
cc
.
loader
.
load
({
url
:
ske
,
type
:
'
txt
'
},
(
error
,
dragonBonesJson
)
=>
{
cc
.
loader
.
load
({
url
:
ske
,
type
:
'
txt
'
},
(
error
,
dragonBonesJson
)
=>
{
const
atlas
=
new
dragonBones
.
DragonBonesAtlasAsset
();
const
atlas
=
new
dragonBones
.
DragonBonesAtlasAsset
();
atlas
.
atlasJson
=
atlasJson
;
atlas
.
atlasJson
=
atlasJson
;
...
@@ -867,7 +870,7 @@ cc.Class({
...
@@ -867,7 +870,7 @@ cc.Class({
// rectNode.addComponent(cc.Button);
// rectNode.addComponent(cc.Button);
animaNode
.
showAnima
=
()
=>
{
animaNode
.
showAnima
=
()
=>
{
animaNode
.
active
=
true
;
animaNode
.
active
=
true
;
// rectNode.on('click', () => {
// rectNode.on('click', () => {
if
(
rectNode
.
isClicked
)
{
if
(
rectNode
.
isClicked
)
{
// return;
// return;
}
}
...
@@ -976,7 +979,7 @@ cc.Class({
...
@@ -976,7 +979,7 @@ cc.Class({
_toCenterShow
(
node
)
{
_toCenterShow
(
node
)
{
const
bgBottom
=
cc
.
find
(
'
Canvas/bgBottom
'
);
const
bgBottom
=
cc
.
find
(
'
Canvas/bgBottom
'
);
cc
.
tween
(
node
)
cc
.
tween
(
node
)
.
to
(
1
,
{
x
:
0
,
y
:
0
,
scale
:
bgBottom
.
scale
},
{
easing
:
'
cubicOut
'
})
.
to
(
1
,
{
x
:
0
,
y
:
0
,
scale
:
bgBottom
.
scale
},
{
easing
:
'
cubicOut
'
})
.
call
(()
=>
{
.
call
(()
=>
{
})
})
.
start
();
.
start
();
...
@@ -999,7 +1002,7 @@ cc.Class({
...
@@ -999,7 +1002,7 @@ cc.Class({
const
changeNode
=
this
.
_curShowItem
;
const
changeNode
=
this
.
_curShowItem
;
changeNode
.
cantouch
=
false
;
changeNode
.
cantouch
=
false
;
cc
.
tween
(
this
.
_curShowItem
)
cc
.
tween
(
this
.
_curShowItem
)
.
to
(
1
,
{
scale
:
s
*
0.95
,
x
:
localPos
.
x
,
y
:
localPos
.
y
},
{
easing
:
'
cubicOut
'
})
.
to
(
1
,
{
scale
:
s
*
0.95
,
x
:
localPos
.
x
,
y
:
localPos
.
y
},
{
easing
:
'
cubicOut
'
})
.
call
(()
=>
{
.
call
(()
=>
{
changeNode
.
cantouch
=
true
;
changeNode
.
cantouch
=
true
;
})
})
...
@@ -1150,8 +1153,8 @@ cc.Class({
...
@@ -1150,8 +1153,8 @@ cc.Class({
const
backItem
=
this
.
_curShowItem
;
const
backItem
=
this
.
_curShowItem
;
cc
.
tween
(
backItem
)
cc
.
tween
(
backItem
)
.
to
(
0.3
,
{
x
:
backItem
.
baseX
,
y
:
backItem
.
baseY
},
{
easing
:
'
elasticOut
'
})
.
to
(
0.3
,
{
x
:
backItem
.
baseX
,
y
:
backItem
.
baseY
},
{
easing
:
'
elasticOut
'
})
.
call
((
)
=>
{
.
call
(()
=>
{
backItem
.
bgBottomItem
.
opacity
=
255
;
backItem
.
bgBottomItem
.
opacity
=
255
;
backItem
.
removeFromParent
();
backItem
.
removeFromParent
();
backItem
.
data
.
isDrag
=
false
;
backItem
.
data
.
isDrag
=
false
;
...
...
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