Commit 82165ba0 by Eddy Guo

feat: add teacher

parent 343efb3b
......@@ -68,29 +68,29 @@
"__id__": 17
},
{
"__id__": 18
"__id__": 23
},
{
"__id__": 19
"__id__": 24
},
{
"__id__": 23
"__id__": 28
},
{
"__id__": 25
"__id__": 30
},
{
"__id__": 26
"__id__": 31
}
],
"_tag": -1,
"_active": true,
"_components": [
{
"__id__": 27
"__id__": 32
},
{
"__id__": 28
"__id__": 33
}
],
"_prefab": null,
......@@ -660,10 +660,21 @@
"_parent": {
"__id__": 2
},
"_children": [],
"_children": [
{
"__id__": 18
},
{
"__id__": 20
}
],
"_tag": -1,
"_active": true,
"_components": [],
"_components": [
{
"__id__": 22
}
],
"_prefab": null,
"_id": "67K6Y1EOVDuJEJ6kufn8TI",
"_opacity": 255,
......@@ -691,6 +702,58 @@
"_scaleY": 1,
"_position": {
"__type__": "cc.Vec2",
"x": -250,
"y": 250
},
"_skewX": 0,
"_skewY": 0,
"_localZOrder": 0,
"_globalZOrder": 0,
"_opacityModifyRGB": false,
"groupIndex": 0
},
{
"__type__": "cc.Node",
"_name": "big_head",
"_objFlags": 0,
"_parent": {
"__id__": 17
},
"_children": [],
"_tag": -1,
"_active": true,
"_components": [
{
"__id__": 19
}
],
"_prefab": null,
"_id": "e4eF8LUmFMkKCN6zt5xtXw",
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_cascadeOpacityEnabled": true,
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_contentSize": {
"__type__": "cc.Size",
"width": 136,
"height": 387
},
"_rotationX": 0,
"_rotationY": 0,
"_scaleX": 0.5,
"_scaleY": 0.5,
"_position": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
......@@ -702,6 +765,130 @@
"groupIndex": 0
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 18
},
"_enabled": true,
"_spriteFrame": {
"__uuid__": "c4a9bff3-8d28-4078-89ca-e7599bfcabde"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_atlas": null
},
{
"__type__": "cc.Node",
"_name": "coming",
"_objFlags": 0,
"_parent": {
"__id__": 17
},
"_children": [],
"_tag": -1,
"_active": true,
"_components": [
{
"__id__": 21
}
],
"_prefab": null,
"_id": "e6dNOdA5JMSYgEseVRdkev",
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_cascadeOpacityEnabled": true,
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_contentSize": {
"__type__": "cc.Size",
"width": 317,
"height": 235
},
"_rotationX": 0,
"_rotationY": 0,
"_scaleX": 0.5,
"_scaleY": 0.5,
"_position": {
"__type__": "cc.Vec2",
"x": -50,
"y": 0
},
"_skewX": 0,
"_skewY": 0,
"_localZOrder": 0,
"_globalZOrder": 0,
"_opacityModifyRGB": false,
"groupIndex": 0
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 20
},
"_enabled": true,
"_spriteFrame": {
"__uuid__": "4caf3387-f8b1-49a7-90c4-5feb4f6e7832"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_atlas": null
},
{
"__type__": "fe722Cl2ZJJ0pHbwd57EfsG",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 17
},
"_enabled": true,
"isSwiveling": false,
"totalTime": 45000,
"animationTime": 1000,
"needSwivelCount": 9,
"game": null,
"bigHead": {
"__id__": 18
},
"coming": {
"__id__": 20
}
},
{
"__type__": "cc.Node",
"_name": "student",
"_objFlags": 0,
......@@ -758,13 +945,13 @@
},
"_children": [
{
"__id__": 20
"__id__": 25
},
{
"__id__": 21
"__id__": 26
},
{
"__id__": 22
"__id__": 27
}
],
"_tag": -1,
......@@ -812,7 +999,7 @@
"_name": "timer",
"_objFlags": 0,
"_parent": {
"__id__": 19
"__id__": 24
},
"_children": [],
"_tag": -1,
......@@ -860,7 +1047,7 @@
"_name": "score",
"_objFlags": 0,
"_parent": {
"__id__": 19
"__id__": 24
},
"_children": [],
"_tag": -1,
......@@ -908,7 +1095,7 @@
"_name": "life",
"_objFlags": 0,
"_parent": {
"__id__": 19
"__id__": 24
},
"_children": [],
"_tag": -1,
......@@ -963,7 +1150,7 @@
"_active": true,
"_components": [
{
"__id__": 24
"__id__": 29
}
],
"_prefab": null,
......@@ -1008,7 +1195,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 23
"__id__": 28
},
"_enabled": true,
"_spriteFrame": {
......@@ -1158,11 +1345,12 @@
"start_btn": {
"__id__": 6
},
"teacher": null,
"classroom": {
"__id__": 15
},
"hand": {
"__id__": 23
"__id__": 28
}
}
]
\ No newline at end of file
{
"ver": "1.0.0",
"uuid": "8dc33d76-6b39-40d8-8abc-3b79c82fb410",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"subMetas": {
"coming": {
"ver": "1.0.3",
"uuid": "4caf3387-f8b1-49a7-90c4-5feb4f6e7832",
"rawTextureUuid": "8dc33d76-6b39-40d8-8abc-3b79c82fb410",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -0.5,
"offsetY": -1.5,
"trimX": 0,
"trimY": 10,
"width": 317,
"height": 235,
"rawWidth": 318,
"rawHeight": 252,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.0.0",
"uuid": "82bfa60c-7c5c-4eb4-994c-30f4290c3980",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"subMetas": {
"teacher": {
"ver": "1.0.3",
"uuid": "c4a9bff3-8d28-4078-89ca-e7599bfcabde",
"rawTextureUuid": "82bfa60c-7c5c-4eb4-994c-30f4290c3980",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -2.5,
"trimX": 0,
"trimY": 5,
"width": 136,
"height": 387,
"rawWidth": 136,
"rawHeight": 392,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.1.0",
"uuid": "977cfe9b-21c7-498e-b060-541800511a8b",
"textureUuid": "f3779477-7dbf-4751-902f-985973720152",
"fontSize": 36,
"subMetas": {}
}
\ No newline at end of file
......@@ -25,6 +25,11 @@ cc.Class({
type: cc.Node,
},
teacher: {
default: null,
type: cc.Node,
},
// classroom节点
classroom: {
default: null,
......@@ -53,7 +58,8 @@ cc.Class({
var startBtn = cc.find("index/start_btn", this.node);
startBtn.getComponent('Start').game = this;
var teacher = cc.find("teacher", this.node);
teacher.getComponent('Teacher').game = this;
},
// 添加分数
......
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
{
"ver": "1.0.5",
"uuid": "fe7220a5-d992-49d2-91db-c1de7b11fb06",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment