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
ff7f7c72
Commit
ff7f7c72
authored
Jan 06, 2022
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 更改为prefab的形式,便于导出
parent
7f038a34
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1211 additions
and
418 deletions
+1211
-418
.DS_Store
.DS_Store
+0
-0
prefabs.meta
play/assets/unit_demo/prefabs.meta
+12
-0
StarScore.prefab
play/assets/unit_demo/prefabs/StarScore.prefab
+587
-0
StarScore.prefab.meta
play/assets/unit_demo/prefabs/StarScore.prefab.meta
+8
-0
StarScore.ts
play/assets/unit_demo/prefabs/StarScore.ts
+79
-0
StarScore.ts.meta
play/assets/unit_demo/prefabs/StarScore.ts.meta
+9
-0
demo_02_scoreStars.fire
play/assets/unit_demo/scene/demo_02_scoreStars.fire
+514
-341
demo_02_scoreStars.js
play/assets/unit_demo/scene/demo_02_scoreStars.js
+2
-77
No files found.
.DS_Store
0 → 100644
View file @
ff7f7c72
File added
play/assets/unit_demo/prefabs.meta
0 → 100644
View file @
ff7f7c72
{
"ver": "1.1.2",
"uuid": "aafdf165-a49b-4d39-9272-f86513fed793",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
play/assets/unit_demo/prefabs/StarScore.prefab
0 → 100644
View file @
ff7f7c72
This diff is collapsed.
Click to expand it.
play/assets/unit_demo/prefabs/StarScore.prefab.meta
0 → 100644
View file @
ff7f7c72
{
"ver": "1.2.9",
"uuid": "cb251ca0-8be4-41e6-9c06-6461d59ff7c0",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
play/assets/unit_demo/prefabs/StarScore.ts
0 → 100644
View file @
ff7f7c72
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
StarScore
extends
cc
.
Component
{
starLength
=
0
;
addStar
()
{
this
.
starLength
++
;
let
length
=
this
.
starLength
;
const
starLayout
=
cc
.
find
(
'
layout
'
,
this
.
node
);
starLayout
.
removeAllChildren
();
const
paddingY
=
starLayout
.
getComponent
(
cc
.
Layout
).
spacingY
;
for
(
let
i
=
0
;
i
<
length
;
i
++
)
{
const
starBase
=
cc
.
instantiate
(
cc
.
find
(
'
StarBase
'
,
this
.
node
));
starBase
.
name
=
`starBase_
${
i
}
`
;
starBase
.
scale
=
this
.
Between
(
0.5
,
(
starLayout
.
height
/
length
-
paddingY
)
/
starBase
.
height
,
1
);
starBase
.
parent
=
starLayout
;
}
this
.
currentStarIdx
=
0
;
}
currentStarIdx
=
0
;
showStar
()
{
const
starBase
=
cc
.
find
(
`layout/starBase_
${
this
.
currentStarIdx
}
`
,
this
.
node
);
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
));
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/unit_demo/prefabs/StarScore.ts.meta
0 → 100644
View file @
ff7f7c72
{
"ver": "1.0.8",
"uuid": "0857bc6c-6ff1-4e05-966e-0c1db1fa3dc2",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
play/assets/unit_demo/scene/demo_02_scoreStars.fire
View file @
ff7f7c72
This diff is collapsed.
Click to expand it.
play/assets/unit_demo/scene/demo_02_scoreStars.js
View file @
ff7f7c72
...
...
@@ -22,86 +22,11 @@ cc.Class({
BtnShowStar
.
on
(
'
click
'
,
this
.
showStar
.
bind
(
this
));
},
starLength
:
null
,
addStar
()
{
if
(
!
this
.
starLength
)
{
this
.
starLength
=
0
;
}
this
.
starLength
++
;
let
length
=
this
.
starLength
;
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
;
cc
.
find
(
'
Canvas/StarScore
'
).
getComponent
(
'
StarScore
'
).
addStar
();
},
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
];
cc
.
find
(
'
Canvas/StarScore
'
).
getComponent
(
'
StarScore
'
).
showStar
();
},
exchangeNodePos
(
targetNode
,
baseNode
,
basePos
)
{
return
targetNode
.
convertToNodeSpaceAR
(
baseNode
.
convertToWorldSpaceAR
(
cc
.
v2
(
basePos
.
x
,
basePos
.
y
)));
},
});
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