Skip to content

Commit 2226d10

Browse files
committed
change5
1 parent 306ca46 commit 2226d10

27 files changed

+2542
-1
lines changed

change5/assets/moon.fire

+1,857
Large diffs are not rendered by default.

change5/assets/moon.fire.meta

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"ver": "1.2.9",
3+
"uuid": "abdcb313-6491-42f6-9b55-80a72fd873f8",
4+
"asyncLoadAssets": false,
5+
"autoReleaseAssets": false,
6+
"subMetas": {}
7+
}

change5/assets/scripts.meta

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"ver": "1.1.2",
3+
"uuid": "cfb7987b-0d13-421d-aa46-5efdf54bbc6c",
4+
"isBundle": false,
5+
"bundleName": "",
6+
"priority": 1,
7+
"compressionType": {},
8+
"optimizeHotUpdate": {},
9+
"inlineSpriteFrames": {},
10+
"isRemoteBundle": {},
11+
"subMetas": {}
12+
}

change5/assets/scripts/Controller.js

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
// Learn cc.Class:
2+
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
3+
// Learn Attribute:
4+
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
5+
// Learn life-cycle callbacks:
6+
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
7+
8+
cc.Class({
9+
extends: cc.Component,
10+
11+
properties: {
12+
change5: cc.Node,
13+
up: cc.Node,
14+
ret: cc.Node,
15+
borer: cc.Node,
16+
soil: cc.Node,
17+
flag: cc.Node,
18+
output: cc.RichText,
19+
ending: cc.Node,
20+
21+
G: -0.01,
22+
F: 0,
23+
R: 0,
24+
phase: 1,
25+
ticks: 0,
26+
27+
// foo: {
28+
// // ATTRIBUTES:
29+
// default: null, // The default value will be used only when the component attaching
30+
// // to a node for the first time
31+
// type: cc.SpriteFrame, // optional, default is typeof default
32+
// serializable: true, // optional, default is true
33+
// },
34+
// bar: {
35+
// get () {
36+
// return this._bar;
37+
// },
38+
// set (value) {
39+
// this._bar = value;
40+
// }
41+
// },
42+
},
43+
44+
// LIFE-CYCLE CALLBACKS:
45+
46+
onLoad () {
47+
cc.debug.setDisplayStats(false);
48+
49+
this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
50+
this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
51+
52+
this.output.string = "1. 月面着陆\n<color=#88ffff>点击屏幕中部:点火减速\n点击屏幕两侧:调整姿态\n注意控制着落时的速度和角度</c>\n";
53+
},
54+
55+
start () {
56+
57+
},
58+
59+
onTouchStart (event) {
60+
var pos = event.getLocation();
61+
if (pos.x < cc.winSize.width / 2 - 100) {
62+
this.R = 0.25;
63+
} else if (pos.x > cc.winSize.width / 2 + 100) {
64+
this.R = -0.25;
65+
} else {
66+
this.F = 10 * 0.005;
67+
}
68+
},
69+
onTouchEnd (event) {
70+
this.F = 0;
71+
this.R = 0;
72+
73+
if (this.phase == 4 && this.ticks > 1) {
74+
cc.game.restart();
75+
}
76+
},
77+
78+
update (dt) {
79+
if (this.phase == 1) {
80+
if (Math.abs(this.change5.x) > 300 || Math.abs(this.change5.y) > 500) {
81+
this.phase = 4;
82+
this.output.string += "<color=#ff8888>偏离目标区域太远,着陆失败!</c>\n点击屏幕再次尝试";
83+
}
84+
if (this.change5.y < -300) {
85+
var c5 = this.change5.getComponent('change5');
86+
if (Math.abs(c5.speed_x) > 1 || Math.abs(c5.speed_y) > 1) {
87+
this.phase = 4;
88+
this.output.string += "<color=#ff8888>速度太快,着陆失败!</c>\n点击屏幕再次尝试";
89+
} else if (Math.abs(this.change5.rotation) > 30) {
90+
this.phase = 4;
91+
this.output.string += "<color=#ff8888>角度太大,着陆失败!</c>\n点击屏幕再次尝试";
92+
} else {
93+
this.phase = 2;
94+
this.output.string += "<color=#88ff88>着陆成功!</c>\n\n2. 月壤采集工作中\n";
95+
this.land();
96+
}
97+
}
98+
} else if (this.phase == 3) {
99+
if (Math.abs(this.up.x) > 300 || Math.abs(this.up.y) > 500) {
100+
this.phase = 4;
101+
this.output.string += "<color=#ff8888>偏离轨道器太远,对接失败!</c>\n点击屏幕再次尝试";
102+
}
103+
if (Math.abs(this.up.y-this.ret.y)<10 && Math.abs(this.up.x-this.ret.x)<10) {
104+
var up = this.up.getComponent('up');
105+
var ret = this.ret.getComponent('return');
106+
if (Math.abs(up.speed_x-0.5) > 1 || Math.abs(up.speed_y) > 1) {
107+
this.output.string += "<color=#ff8888>速度太快,对接失败!</c>\n点击屏幕再次尝试";
108+
} else if (Math.abs(this.change5.rotation) > 30) {
109+
this.output.string += "<color=#ff8888>角度太大,对接失败!</c>\n点击屏幕再次尝试";
110+
} else {
111+
this.output.string += "<color=#88ff88>对接成功!</c>\n任务完成";
112+
this.ending.runAction(cc.fadeIn(1));
113+
}
114+
this.phase = 4;
115+
}
116+
} else if (this.phase == 4) {
117+
this.ticks += dt;
118+
}
119+
},
120+
121+
land () {
122+
var c5 = this.change5;
123+
if (c5.angle == 0) {
124+
this.bore1();
125+
} else {
126+
// 此段为落地后的调整动画,可略过
127+
var dx = c5.width * 0.23 * Math.cos(Math.PI / 180 * c5.angle);
128+
var dy = c5.width * 0.23 * Math.sin(Math.PI / 180 * c5.angle);
129+
if (c5.angle < 0) {
130+
c5.anchorX = 0.73;
131+
c5.x += dx;
132+
c5.y += dy;
133+
} else {
134+
c5.anchorX = 0.27;
135+
c5.x -= dx;
136+
c5.y -= dy;
137+
}
138+
for (var i = c5.children.length - 1; i >= 0; i--) {
139+
var item = c5.children[i];
140+
var sign = c5.anchorX > 0.5 ? -1 : 1;
141+
item.x += sign * c5.width * 0.23;
142+
}
143+
var a1 = cc.rotateTo(Math.abs(c5.angle/45), 0);
144+
var a2 = cc.callFunc(this.bore1, this);
145+
c5.runAction(cc.sequence(a1, a2));
146+
}
147+
},
148+
149+
bore1 () {
150+
this.borer.opacity = 255;
151+
var a1 = cc.scaleTo(2, 1, 20);
152+
var a2 = cc.callFunc(this.bore2, this);
153+
this.borer.runAction(cc.sequence(cc.delayTime(1), a1, cc.delayTime(1), a2));
154+
},
155+
156+
bore2 () {
157+
var a1 = cc.scaleTo(2, 1, 20);
158+
this.soil.y = this.borer.y - this.borer.height * this.borer.scaleY;
159+
this.soil.opacity = 255;
160+
var a2 = cc.callFunc(this.bore3, this);
161+
this.soil.runAction(cc.sequence(a1, cc.delayTime(2), a2));
162+
},
163+
164+
bore3 () {
165+
var a1 = cc.scaleTo(2, 1, 0.1);
166+
this.soil.anchorY = 1;
167+
this.soil.y = this.borer.y;
168+
var a2 = cc.callFunc(this.flag1, this);
169+
this.soil.runAction(cc.sequence(a1, cc.delayTime(1), a2));
170+
},
171+
172+
flag1 () {
173+
this.flag.opacity = 255;
174+
var a1 = cc.rotateTo(1, 360);
175+
var a2 = cc.callFunc(this.flag2, this);
176+
this.flag.runAction(cc.sequence(a1, a2));
177+
},
178+
179+
flag2 () {
180+
this.phase = 3;
181+
this.output.string += "<color=#88ff88>采集完毕!</c>\n\n3. 月面上升\n<color=#88ffff>点击屏幕中部:点火上升\n点击屏幕两侧:调整姿态\n注意控制对接时的速度和角度</c>\n";
182+
},
183+
184+
restart () {
185+
186+
}
187+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"ver": "1.0.8",
3+
"uuid": "0bd341a0-4660-4198-9d24-74a16bbf7bb4",
4+
"isPlugin": false,
5+
"loadPluginInWeb": true,
6+
"loadPluginInNative": true,
7+
"loadPluginInEditor": false,
8+
"subMetas": {}
9+
}

change5/assets/scripts/change5.js

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Learn cc.Class:
2+
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
3+
// Learn Attribute:
4+
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
5+
// Learn life-cycle callbacks:
6+
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
7+
8+
cc.Class({
9+
extends: cc.Component,
10+
11+
properties: {
12+
speed_x: 0,
13+
speed_y: 0,
14+
flame: cc.Node,
15+
// foo: {
16+
// // ATTRIBUTES:
17+
// default: null, // The default value will be used only when the component attaching
18+
// // to a node for the first time
19+
// type: cc.SpriteFrame, // optional, default is typeof default
20+
// serializable: true, // optional, default is true
21+
// },
22+
// bar: {
23+
// get () {
24+
// return this._bar;
25+
// },
26+
// set (value) {
27+
// this._bar = value;
28+
// }
29+
// },
30+
},
31+
32+
// LIFE-CYCLE CALLBACKS:
33+
34+
onLoad () {
35+
this.ctrl = this.node.parent.getComponent('Controller');
36+
this.flame.opacity = 0;
37+
},
38+
39+
start () {
40+
41+
},
42+
43+
update (dt) {
44+
if (this.ctrl.phase == 1) {
45+
var change = this.node;
46+
this.speed_y += this.ctrl.G;
47+
48+
var f_x = Math.sin(-Math.PI / 180 * change.angle);
49+
var f_y = Math.cos(Math.PI / 180 * change.angle);
50+
this.speed_x *= 1.001;
51+
this.speed_x += f_x * this.ctrl.F;
52+
this.speed_y += f_y * this.ctrl.F;
53+
54+
change.x += this.speed_x * dt * 60;
55+
change.y += this.speed_y * dt * 60;
56+
change.angle += this.ctrl.R;
57+
58+
if (this.ctrl.F > 0) {
59+
this.flame.opacity = 255;
60+
} else {
61+
this.flame.opacity = 0;
62+
}
63+
} else {
64+
this.flame.opacity = 0;
65+
}
66+
},
67+
});
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"ver": "1.0.8",
3+
"uuid": "bb3b0693-1fc9-42a4-90bb-b37c260a1615",
4+
"isPlugin": false,
5+
"loadPluginInWeb": true,
6+
"loadPluginInNative": true,
7+
"loadPluginInEditor": false,
8+
"subMetas": {}
9+
}

change5/assets/scripts/return.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Learn cc.Class:
2+
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
3+
// Learn Attribute:
4+
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
5+
// Learn life-cycle callbacks:
6+
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
7+
8+
cc.Class({
9+
extends: cc.Component,
10+
11+
properties: {
12+
// foo: {
13+
// // ATTRIBUTES:
14+
// default: null, // The default value will be used only when the component attaching
15+
// // to a node for the first time
16+
// type: cc.SpriteFrame, // optional, default is typeof default
17+
// serializable: true, // optional, default is true
18+
// },
19+
// bar: {
20+
// get () {
21+
// return this._bar;
22+
// },
23+
// set (value) {
24+
// this._bar = value;
25+
// }
26+
// },
27+
},
28+
29+
// LIFE-CYCLE CALLBACKS:
30+
31+
onLoad () {
32+
this.ctrl = this.node.parent.getComponent('Controller');
33+
},
34+
35+
start () {
36+
37+
},
38+
39+
update (dt) {
40+
if (this.ctrl.phase != 4) {
41+
this.node.x += dt * 50;
42+
if (this.node.x > 600) {
43+
this.node.x = -400;
44+
}
45+
}
46+
},
47+
});

change5/assets/scripts/return.js.meta

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"ver": "1.0.8",
3+
"uuid": "31a7c9ab-e6b9-49e3-acdd-0b8ad0f8c429",
4+
"isPlugin": false,
5+
"loadPluginInWeb": true,
6+
"loadPluginInNative": true,
7+
"loadPluginInEditor": false,
8+
"subMetas": {}
9+
}

0 commit comments

Comments
 (0)