Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fucking_flirt
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
william
fucking_flirt
Commits
6bcf80b4
Commit
6bcf80b4
authored
May 05, 2018
by
Eddy Guo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add teacher
parent
5cccc552
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
1 deletion
+104
-1
coming.png
assets/images/coming.png
+0
-0
teacher.png
assets/images/teacher.png
+0
-0
Game.js
assets/scripts/Game.js
+7
-1
Teacher.js
assets/scripts/Teacher.js
+97
-0
No files found.
assets/images/coming.png
0 → 100644
View file @
6bcf80b4
14.5 KB
assets/images/teacher.png
0 → 100644
View file @
6bcf80b4
49.1 KB
assets/scripts/Game.js
View file @
6bcf80b4
...
@@ -25,6 +25,11 @@ cc.Class({
...
@@ -25,6 +25,11 @@ cc.Class({
type
:
cc
.
Node
,
type
:
cc
.
Node
,
},
},
teacher
:
{
default
:
null
,
type
:
cc
.
Node
,
},
// classroom节点
// classroom节点
classroom
:
{
classroom
:
{
default
:
null
,
default
:
null
,
...
@@ -53,7 +58,8 @@ cc.Class({
...
@@ -53,7 +58,8 @@ cc.Class({
var
startBtn
=
cc
.
find
(
"index/start_btn"
,
this
.
node
);
var
startBtn
=
cc
.
find
(
"index/start_btn"
,
this
.
node
);
startBtn
.
getComponent
(
'Start'
).
game
=
this
;
startBtn
.
getComponent
(
'Start'
).
game
=
this
;
var
teacher
=
cc
.
find
(
"teacher"
,
this
.
node
);
teacher
.
getComponent
(
'Teacher'
).
game
=
this
;
},
},
// 添加分数
// 添加分数
...
...
assets/scripts/Teacher.js
0 → 100644
View file @
6bcf80b4
cc
.
Class
({
extends
:
cc
.
Component
,
properties
:
{
isSwiveling
:
false
,
// 是否回头
totalTime
:
45
*
1000
,
// 总时间, bed
animationTime
:
1
*
1000
,
// 转头过程单位时间, bed
needSwivelCount
:
10
,
// 需要回头的次数
game
:
{
default
:
null
,
type
:
cc
.
Node
,
},
bigHead
:
{
default
:
null
,
type
:
cc
.
Node
,
},
coming
:
{
default
:
null
,
type
:
cc
.
Node
,
}
},
onLoad
:
function
()
{
this
.
startSwivel
()
},
swivelAnimation
:
function
()
{
var
time
=
this
.
animationTime
/
8
/
1000
var
enableSwivel
=
cc
.
callFunc
(
function
()
{
this
.
isSwiveling
=
true
},
this
)
var
disableSwivel
=
cc
.
callFunc
(
function
()
{
this
.
isSwiveling
=
false
},
this
)
var
coming
=
cc
.
find
(
"coming"
,
this
.
node
)
var
bigHead
=
cc
.
find
(
"big_head"
,
this
.
node
)
var
comingAction
=
cc
.
sequence
(
cc
.
moveTo
(
time
,
cc
.
p
(
100
,
0
)),
cc
.
delayTime
(
time
),
cc
.
moveTo
(
time
,
cc
.
p
(
-
50
,
0
)),
cc
.
delayTime
(
time
)
)
var
action
=
cc
.
sequence
(
cc
.
delayTime
(
time
*
4
),
// for coming time
cc
.
moveTo
(
time
,
cc
.
p
(
100
,
0
)),
enableSwivel
,
cc
.
delayTime
(
4
*
time
),
cc
.
moveTo
(
time
,
cc
.
p
(
0
,
0
)),
disableSwivel
,
)
coming
.
runAction
(
comingAction
)
bigHead
.
runAction
(
action
)
},
update
:
function
(
dt
)
{
console
.
log
(
'🐞-checking'
,
this
.
isSwiveling
)
},
// 获取转头时间的数组, [0.6, 1.2, 2.3, 3.4, 4.8, 5.2, 6.3]
getSwivelTimeArray
:
function
(
totalTime
,
count
,
animationTime
)
{
var
timeArray
=
[]
var
interval
=
totalTime
/
count
var
ratio
=
animationTime
/
interval
// 每个时间段前后间隔,避免边界情况
for
(
var
i
=
0
;
i
<
count
;
i
++
)
{
// var rand = (Math.random() + i) * interval
var
rand
=
(
Math
.
random
()
*
(
1
-
(
ratio
/
2
))
+
i
)
*
interval
+
(
animationTime
/
2
)
timeArray
.
push
(
rand
)
}
return
timeArray
},
startSwivel
:
function
()
{
var
swivelTimeArray
=
this
.
getSwivelTimeArray
(
this
.
totalTime
,
this
.
needSwivelCount
,
this
.
animationTime
)
var
lastTime
var
swivelFunc
=
(
timeArray
)
=>
{
const
nextTime
=
timeArray
.
shift
()
if
(
nextTime
)
{
var
intervel
=
!!
lastTime
?
(
nextTime
-
lastTime
)
:
nextTime
// 获取下一次的时间间隔
lastTime
=
nextTime
this
.
swivelAnimation
()
setTimeout
(()
=>
{
swivelFunc
(
timeArray
)
},
intervel
)
}
}
swivelFunc
(
swivelTimeArray
)
},
})
\ 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