Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
unit_demo
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
unit_demo
Commits
420775d8
Commit
420775d8
authored
Mar 18, 2021
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 增加星星飞行效果
parent
ff4cde55
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1222 additions
and
74 deletions
+1222
-74
demo_02_scoreStars.fire
play/assets/tmpGame/scene/demo_02_scoreStars.fire
+1065
-59
demo_02_scoreStars.js
play/assets/tmpGame/scene/demo_02_scoreStars.js
+85
-15
icon_bigstar.png
play/assets/tmpGame/textures/icon_bigstar.png
+0
-0
icon_bigstar.png.meta
play/assets/tmpGame/textures/icon_bigstar.png.meta
+36
-0
icon_star.png
play/assets/tmpGame/textures/icon_star.png
+0
-0
icon_star.png.meta
play/assets/tmpGame/textures/icon_star.png.meta
+36
-0
No files found.
play/assets/tmpGame/scene/demo_02_scoreStars.fire
View file @
420775d8
This diff is collapsed.
Click to expand it.
play/assets/tmpGame/scene/demo_02_scoreStars.js
View file @
420775d8
...
...
@@ -11,27 +11,97 @@ cc.Class({
properties
:
{
},
start
()
{
this
.
initListeners
();
},
initListeners
()
{
const
BtnAddStar
=
cc
.
find
(
'
Canvas/BtnAddStar
'
);
BtnAddStar
.
on
(
'
click
'
,
this
.
addStar
.
bind
(
this
));
const
BtnShowStar
=
cc
.
find
(
'
Canvas/BtnShowStar
'
);
BtnShowStar
.
on
(
'
click
'
,
this
.
showStar
.
bind
(
this
));
},
let
length
=
0
;
setInterval
(()
=>
{
const
starLayout
=
cc
.
find
(
'
Canvas/layout
'
);
starLayout
.
removeAllChildren
();
const
paddingY
=
starLayout
.
getComponent
(
cc
.
Layout
).
spacingY
;
for
(
let
i
=
0
;
i
<
length
;
i
++
)
{
const
star
=
cc
.
instantiate
(
cc
.
find
(
'
Star
'
));
star
.
name
=
`star_
${
i
}
`
;
star
.
scale
=
this
.
Between
(
0.5
,
1
,
(
starLayout
.
height
/
length
-
paddingY
)
/
star
.
height
);
star
.
parent
=
starLayout
;
}
length
++
;
},
1000
);
length
,
addStar
()
{
if
(
!
this
.
length
)
{
this
.
length
=
0
;
}
this
.
length
++
;
let
length
=
this
.
length
;
const
starLayout
=
cc
.
find
(
'
Canvas/layout
'
);
starLayout
.
removeAllChildren
();
const
paddingY
=
starLayout
.
getComponent
(
cc
.
Layout
).
spacingY
;
for
(
let
i
=
0
;
i
<
length
;
i
++
)
{
const
starBase
=
cc
.
instantiate
(
cc
.
find
(
'
StarBase
'
));
starBase
.
name
=
`starBase_
${
i
}
`
;
starBase
.
scale
=
this
.
Between
(
0.5
,
(
starLayout
.
height
/
length
-
paddingY
)
/
starBase
.
height
,
1
);
starBase
.
parent
=
starLayout
;
}
this
.
currentStarIdx
=
0
;
},
currentStarIdx
:
null
,
showStar
()
{
if
(
!
this
.
currentStarIdx
)
{
this
.
currentStarIdx
=
0
;
}
const
starBase
=
cc
.
find
(
`Canvas/layout/starBase_
${
this
.
currentStarIdx
}
`
);
if
(
!
starBase
)
{
return
;
}
const
star
=
starBase
.
getChildByName
(
'
Star
'
);
const
starBig
=
star
.
getChildByName
(
'
StarBig
'
);
starBig
.
scale
=
1
;
star
.
active
=
true
;
star
.
scaleX
=
0.7
/
starBase
.
scale
;
star
.
scaleY
=
1
/
starBase
.
scale
;
star
.
angle
=
90
;
const
canvas
=
cc
.
find
(
'
Canvas
'
);
const
startPos
=
this
.
exchangeNodePos
(
star
.
parent
,
canvas
,
cc
.
v2
(
0
,
-
canvas
.
height
/
2
));
const
middlePos
=
this
.
exchangeNodePos
(
star
.
parent
,
canvas
,
cc
.
v2
(
0
,
-
canvas
.
height
/
4
));
star
.
x
=
startPos
.
x
;
star
.
y
=
startPos
.
y
-
starBig
.
height
;
console
.
log
(
'
middlePos =
'
+
JSON
.
stringify
(
middlePos
));
const
time
=
1
;
cc
.
tween
(
star
)
.
to
(
0.3
,
{
y
:
middlePos
.
y
+
80
},
{
easing
:
'
quadOut
'
})
.
to
(
0.1
,
{
y
:
middlePos
.
y
+
40
,
scaleX
:
1.2
/
starBase
.
scale
,
scaleY
:
0.8
/
starBase
.
scale
},
{
easing
:
'
quadOut
'
})
.
to
(
0.1
,
{
y
:
middlePos
.
y
,
scaleX
:
1
/
starBase
.
scale
,
scaleY
:
1
/
starBase
.
scale
},
{
easing
:
'
quadOut
'
})
.
delay
(
0.1
)
.
to
(
0.8
,
{
angle
:
-
720
,
scale
:
1
})
.
start
();
cc
.
tween
(
star
)
.
delay
(
0.6
)
.
to
(
0.8
,
{
x
:
0
},
{
easing
:
'
quadIn
'
})
.
start
();
cc
.
tween
(
star
)
.
delay
(
0.6
)
.
to
(
0.8
,
{
y
:
0
},
{
easing
:
'
quadOut
'
})
.
start
();
cc
.
tween
(
starBig
)
.
delay
(
0.6
)
.
to
(
0.8
,
{
scale
:
0
},
{
easing
:
'
quadOut
'
})
.
call
(()
=>
{
// this.checkGameEnd();
})
.
start
();
this
.
currentStarIdx
++
;
},
Between
(
a
,
b
,
c
)
{
return
[
a
,
b
,
c
].
sort
()[
1
];
},
exchangeNodePos
(
targetNode
,
baseNode
,
basePos
)
{
return
targetNode
.
convertToNodeSpaceAR
(
baseNode
.
convertToWorldSpaceAR
(
cc
.
v2
(
basePos
.
x
,
basePos
.
y
)));
},
});
play/assets/tmpGame/textures/icon_bigstar.png
0 → 100644
View file @
420775d8
14.5 KB
play/assets/tmpGame/textures/icon_bigstar.png.meta
0 → 100644
View file @
420775d8
{
"ver": "2.3.5",
"uuid": "f52d3699-7f54-4afe-ae7e-57ed7fb43ba7",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 278,
"height": 275,
"platformSettings": {},
"subMetas": {
"icon_bigstar": {
"ver": "1.0.4",
"uuid": "b00d89ac-54ee-4b06-878a-acef8c97f0df",
"rawTextureUuid": "f52d3699-7f54-4afe-ae7e-57ed7fb43ba7",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 278,
"height": 275,
"rawWidth": 278,
"rawHeight": 275,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
play/assets/tmpGame/textures/icon_star.png
0 → 100644
View file @
420775d8
3.61 KB
play/assets/tmpGame/textures/icon_star.png.meta
0 → 100644
View file @
420775d8
{
"ver": "2.3.5",
"uuid": "a3af0e38-26ac-48a5-b033-cdb020817fc9",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 62,
"height": 69,
"platformSettings": {},
"subMetas": {
"icon_star": {
"ver": "1.0.4",
"uuid": "f72965fe-cf21-4551-adcb-6bdc04be67a0",
"rawTextureUuid": "a3af0e38-26ac-48a5-b033-cdb020817fc9",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 62,
"height": 69,
"rawWidth": 62,
"rawHeight": 69,
"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