├── .gitignore
├── Super Mario in Cocos Creator English.md
├── Super Mario in Cocos Creator.md
├── assets
├── map.meta
├── map
│ ├── level01.png
│ ├── level01.png.meta
│ ├── level01.tmx
│ └── level01.tmx.meta
├── object.meta
├── object
│ ├── beetle.meta
│ ├── beetle
│ │ ├── beetle_anim.anim
│ │ ├── beetle_anim.anim.meta
│ │ ├── beetle_anim2.anim
│ │ ├── beetle_anim2.anim.meta
│ │ ├── beetle_node.prefab
│ │ ├── beetle_node.prefab.meta
│ │ ├── beetle_script.ts
│ │ ├── beetle_script.ts.meta
│ │ ├── beetle_skin.plist
│ │ ├── beetle_skin.plist.meta
│ │ ├── beetle_skin.png
│ │ └── beetle_skin.png.meta
│ ├── block.meta
│ ├── block
│ │ ├── block_anim.anim
│ │ ├── block_anim.anim.meta
│ │ ├── block_anim2.anim
│ │ ├── block_anim2.anim.meta
│ │ ├── block_node.prefab
│ │ ├── block_node.prefab.meta
│ │ ├── block_script.ts
│ │ └── block_script.ts.meta
│ ├── castle.meta
│ ├── castle
│ │ ├── castle_node.prefab
│ │ ├── castle_node.prefab.meta
│ │ ├── castle_script.ts
│ │ ├── castle_script.ts.meta
│ │ ├── castle_skin.png
│ │ └── castle_skin.png.meta
│ ├── coin.meta
│ ├── coin
│ │ ├── coin.mp3
│ │ ├── coin.mp3.meta
│ │ ├── coin_anim.anim
│ │ ├── coin_anim.anim.meta
│ │ ├── coin_jump_node.prefab
│ │ ├── coin_jump_node.prefab.meta
│ │ ├── coin_node.prefab
│ │ ├── coin_node.prefab.meta
│ │ ├── coin_script.ts
│ │ ├── coin_script.ts.meta
│ │ ├── coin_skin.plist
│ │ ├── coin_skin.plist.meta
│ │ ├── coin_skin.png
│ │ └── coin_skin.png.meta
│ ├── mushroom.meta
│ ├── mushroom
│ │ ├── mushroom_appear.mp3
│ │ ├── mushroom_appear.mp3.meta
│ │ ├── mushroom_catch.mp3
│ │ ├── mushroom_catch.mp3.meta
│ │ ├── mushroom_node.prefab
│ │ ├── mushroom_node.prefab.meta
│ │ ├── mushroom_script.ts
│ │ ├── mushroom_script.ts.meta
│ │ ├── mushroom_skin.plist
│ │ ├── mushroom_skin.plist.meta
│ │ ├── mushroom_skin.png
│ │ └── mushroom_skin.png.meta
│ ├── player.meta
│ ├── player
│ │ ├── player.prefab
│ │ ├── player.prefab.meta
│ │ ├── skin.meta
│ │ └── skin
│ │ │ ├── rabbit.meta
│ │ │ └── rabbit
│ │ │ ├── player.anim
│ │ │ ├── player.anim.meta
│ │ │ ├── player.plist
│ │ │ ├── player.plist.meta
│ │ │ ├── player.png
│ │ │ ├── player.png.meta
│ │ │ ├── player_die.anim
│ │ │ ├── player_die.anim.meta
│ │ │ ├── player_hunker.anim
│ │ │ ├── player_hunker.anim.meta
│ │ │ ├── player_idle.anim
│ │ │ ├── player_idle.anim.meta
│ │ │ ├── player_jump.anim
│ │ │ ├── player_jump.anim.meta
│ │ │ ├── player_run.anim
│ │ │ ├── player_run.anim.meta
│ │ │ ├── player_walk.anim
│ │ │ └── player_walk.anim.meta
│ ├── snail.meta
│ ├── snail
│ │ ├── snail_anim.anim
│ │ ├── snail_anim.anim.meta
│ │ ├── snail_anim2.anim
│ │ ├── snail_anim2.anim.meta
│ │ ├── snail_block.prefab
│ │ ├── snail_block.prefab.meta
│ │ ├── snail_node.prefab
│ │ ├── snail_node.prefab.meta
│ │ ├── snail_script.ts
│ │ ├── snail_script.ts.meta
│ │ ├── snail_skin.plist
│ │ ├── snail_skin.plist.meta
│ │ ├── snail_skin.png
│ │ └── snail_skin.png.meta
│ ├── static.meta
│ ├── static
│ │ ├── empty_node.prefab
│ │ └── empty_node.prefab.meta
│ ├── wall.meta
│ └── wall
│ │ ├── wall_breakable_node.prefab
│ │ ├── wall_breakable_node.prefab.meta
│ │ ├── wall_breakable_skin.png
│ │ ├── wall_breakable_skin.png.meta
│ │ ├── wall_node.prefab
│ │ ├── wall_node.prefab.meta
│ │ ├── wall_skin.png
│ │ └── wall_skin.png.meta
├── scene.meta
├── scene
│ ├── game.fire
│ └── game.fire.meta
├── script.meta
├── script
│ ├── lookat.ts
│ ├── lookat.ts.meta
│ ├── main.ts
│ ├── main.ts.meta
│ ├── player.ts
│ ├── player.ts.meta
│ ├── world.ts
│ ├── world.ts.meta
│ ├── worldmap.ts
│ └── worldmap.ts.meta
├── sound.meta
├── sound
│ ├── enemy_killed.mp3
│ └── enemy_killed.mp3.meta
├── texture.meta
└── texture
│ ├── gamebg.png
│ └── gamebg.png.meta
├── creator.d.ts
├── jsconfig.json
├── md
├── 014B076F-900E-44D4-AEEE-7692B34B97B9.png
├── 0F978144-7A1C-4C90-9C9E-386285F69747.png
├── 239F9545-E5BE-4751-AC87-6EACCBD51FD1.png
├── D99BE452-D17D-4C69-B6B6-106797270656.png
├── EDE465D0-92A2-4D7D-A06D-00BFBDE0B393.png
├── image-20190731111104819.png
├── image-20190731141951163.png
├── image-20190731170024369.png
├── image-20190731170101522.png
├── image-20190731172137708.png
└── image-20190731172239417.png
├── project.json
├── settings
├── builder.json
├── builder.panel.json
├── project.json
└── services.json
├── template-banner.png
├── template.json
└── tsconfig.json
/.gitignore:
--------------------------------------------------------------------------------
1 | library
2 | temp
3 | local
4 |
--------------------------------------------------------------------------------
/Super Mario in Cocos Creator English.md:
--------------------------------------------------------------------------------
1 | # Super Mario in Cocos Creator
2 |
3 | This tutorial demonstrates how to use CocosCreator to design Super Mario classic game flexibly and quickly. The main purpose of this tutorial is to help you familiarize yourself with the usage of the following components.
4 |
5 | [TileMap](https://docs.cocos.com/creator/manual/en/asset-workflow/tiledmap.html)
6 |
7 | [Collision System](https://docs.cocos.com/creator/manual/en/physics/collision/)
8 |
9 | [Prefab](https://docs.cocos.com/creator/manual/en/asset-workflow/prefab.html)
10 |
11 | [Keyboard Event](https://docs.cocos.com/creator/manual/en/scripting/player-controls.html#keyboard-events)
12 |
13 | [Atlas](https://docs.cocos.com/creator/manual/en/asset-workflow/atlas.html)
14 |
15 | This tutorial is based on the Cocos Creator v2.x version, click [Download](https://cocos2d-x.org/download) and install it.
16 |
17 | ## Start our game production
18 |
19 | Let's take a look at the effects we finally achieved (all art resources come to the Internet). 
20 |
21 | ## Game Scene Design
22 |
23 | Referring to Super Marie's worldview, we build our world node tree in [Node Manager](https://docs.cocos.com/creator/manual/en/content-workflow/node-tree.html) first, add Camera, background layer, world root, map, and role node.
24 |
25 | 
26 |
27 | ### Add Camera (Main Camera)
28 |
29 | The camera acts as a window for the player to observe the game world. By default, Creator automatically assigns a [camera](https://docs.cocos.com/creator/manual/en/render/camera.html) to the scene, which we don't need to add manually.
30 |
31 | ### Add World Root (World Root)
32 |
33 | Add an empty node and rename World Root, to place the object nodes in the game.
34 |
35 | 1. Create the script world.ts and drag it into the node properties panel, then configure the game world parameters, such as setting the value of the gravitational acceleration G.
36 | 2. Create the script lookat.ts and drag it into the node properties panel to synchronize the world perspective based on the location of the Player node. 
37 |
38 | Global configuration world.ts code:
39 |
40 | ```typescript
41 |
42 | Const {ccclass, property} = cc._decorator;
43 |
44 | @ccclass
45 | Export default class CWorld extends cc.Component {
46 |
47 | @property()
48 | WorldFallG: number = 0;
49 |
50 | @property()
51 | WorldWalkA: number = 0;
52 |
53 | Static G: number = 0;
54 | Static WalkA: number = 0;
55 |
56 | // LIFE-CYCLE CALLBACKS:
57 |
58 | onLoad () {
59 | CWorld.G = this.WorldFallG;
60 | CWorld.WalkA = this.WorldWalkA;
61 | }
62 |
63 | Start () {
64 | // enable Collision System
65 | cc.director.getCollisionManager().enabled = true;
66 | cc.director.getCollisionManager().enabledDebugDraw = true;
67 | cc.director.getCollisionManager().enabledDrawBoundingBox = true;
68 | }
69 |
70 | // update (dt) {}
71 | }
72 | ```
73 |
74 | World perspective control lookat.ts code:
75 |
76 | ```typescript
77 | Const { ccclass, property } = cc._decorator;
78 |
79 | @ccclass
80 | Export default class NewClass extends cc.Component {
81 |
82 | @property(cc.Node)
83 | Target: cc.Node = null;
84 |
85 | @property(cc.Node)
86 | Map: cc.Node = null;
87 |
88 | boundingBox: cc.Rect = null;
89 | screenMiddle: cc.Vec2 = null;
90 |
91 | minX: number = 0;
92 | maxX: number = 0;
93 | minY: number = 0;
94 | maxY: number = 0;
95 |
96 | isRun: boolean = true;
97 |
98 | // LIFE-CYCLE CALLBACKS:
99 |
100 | onLoad() {
101 | this.boundingBox = new cc.Rect(0, 0, this.map.width, this.map.height);
102 | Let winsize = cc.winSize;
103 | this.screenMiddle = new cc.Vec2(winsize.width / 2, winsize.height / 2);
104 | this.minX = -(this.boundingBox.xMax - winsize.width);
105 | this.maxX = this.boundingBox.xMin;
106 | this.minY = -(this.boundingBox.yMax - winsize.height);
107 | this.maxY = this.boundingBox.yMin;
108 | }
109 |
110 | Update() {
111 | If (!this.isRun)
112 | Return;
113 |
114 | Let pos = this.node.convertToWorldSpaceAR(cc.Vec2.ZERO);
115 | Let targertPos = this.target.convertToWorldSpaceAR(cc.Vec2.ZERO);
116 | Let dis = pos.sub(targertPos);
117 | Let dest = this.screenMiddle.add(dis);
118 | Dest.x = cc.misc.clampf(dest.x, this.minX, this.maxX);
119 | Dest.y = this.minY;
120 | This.node.position = this.node.parent.convertToNodeSpaceAR(dest);
121 | }
122 | }
123 | ```
124 | ### Adding a role (Player)
125 |
126 | The Player node we control is the focus of the game world perspective.
127 |
128 | ### Adding a map (Tiled Map)
129 |
130 | [The map resource level01 is created by [Tiled](https://www.mapeditor.org/) (supports TiledMap v1.0) , now dragged level01 into the world node. The map node will be generated automatically. At this time, you can view map levels by expand TiledMap.
131 |
132 | 
133 |
134 | According to the object type designed by TiledMap, we need to instantiate the object. We create the waorldmap.ts script to do the work. The following figure shows the Prefab resources bind for the map level objects we have configured in [Tiled](https://www.mapeditor.org/) (supports TiledMap v1.0).
135 |
136 | 
137 |
138 | The instantiation of a map object is divided into several steps:
139 |
140 | - Prefab resources corresponding to the instantiation type
141 | - Set up a collision group
142 | - Set the object size
143 | - Add collision components
144 | - Set the type tag of the object
145 |
146 | In waorldmap.ts, the instantiation of a water object is as follows:
147 |
148 | ```typescript
149 | // get waters layer and traverse all water objects.
150 | Var waters = this.worldMap.getObjectGroup(this.waterLayerName);
151 | For (var i = 1; i < 8; i++) {
152 | Var waterName = 'water' + i;
153 | Var waterBlock = waters.getObject(waterName);
154 | Var waterNode = cc.instantiate(this.ColliderPreName);
155 |
156 | // set group name for Collider System.
157 | waterNode.group = 'water';
158 |
159 | // set size
160 | waterNode.width = waterBlock.width;
161 | waterNode.height = waterBlock.height;
162 | waterNode.x = waterBlock.x;
163 | waterNode.y = waterBlock.y - waterBlock.height;
164 |
165 | // add collider component.
166 | waterNode.addComponent(cc.BoxCollider);
167 | waterNode.getComponent(cc.BoxCollider).size = cc.size(waterNode.width, waterNode.height);
168 | waterNode.getComponent(cc.BoxCollider).offset =
169 | New cc.Vec2(waterNode.width / 2, -waterNode.height / 2);
170 |
171 | // set tag for check when collision.
172 | waterNode.getComponent(cc.BoxCollider).tag = 6;
173 | this.node.addChild(waterNode);
174 | }
175 | ```
176 |
177 | ### Add collision rules
178 |
179 | World objects contain characters, ground, squares, gold coins, beetles, water, mushrooms, now create collision groups and collision groups to constrain the collision rules between objects.
180 |
181 | 
182 |
183 | ## Game Object Design
184 |
185 | The game objects are classified into Prefab according to their own characteristics. The Prefab add the following contents according to the characteristics of the objects:
186 |
187 | - Collision
188 | - Animation
189 | - Sound
190 | - Behavior
191 |
192 | ### Object Prefab production
193 |
194 | For example, here is the Beetle's resource directory, which contains the Beetle animation file **beetle_anim**, the Prefab resource **beetle_node**, the skin file **beetle_skin**, the behavior control script **beetle_script**.
195 |
196 | |
197 |
198 | Add action components to the beetle Prefab
199 |
200 | 
201 |
202 | Add a collision component to the beetle Prefab
203 |
204 | 
205 |
206 | Add a script component to the Beetle Prefab to set the speed, zoom factor, sound effects, etc.
207 |
208 | 
209 |
210 | Below is the production of the Beetle script for collision detection and behavior control.
211 |
212 | ```typescript
213 | Const { ccclass, property } = cc._decorator;
214 |
215 | @ccclass
216 | Export default class enemy extends cc.Component {
217 | @property()
218 | Speed: cc.Vec2 = new cc.Vec2(0, 0);
219 |
220 | @property
221 | scaleX: number = 1;
222 |
223 | @property
224 | canMove: boolean = true;
225 |
226 | @property({type: cc.AudioClip})
227 | dieAudio: cc.AudioClip = null;
228 |
229 | Anim: cc.Animation = null;
230 |
231 | // LIFE-CYCLE CALLBACKS:
232 |
233 | onLoad() {
234 | this.node.scaleX = 1;
235 | This.anim = this.getComponent(cc.Animation);
236 | }
237 |
238 | Start() {
239 |
240 | }
241 |
242 | // onCollisionEnter overrated
243 | onCollisionEnter(other, self) {
244 | If (other.tag == 5) {
245 | This.turn();
246 | This.speed.x = -this.speed.x;
247 | }
248 |
249 | Var otherAabb = other.world.aabb;
250 | Var otherPreAabb = other.world.preAabb.clone();
251 |
252 | Var selfAabb = self.world.aabb;
253 | Var selfPreAabb = self.world.preAabb.clone();
254 | selfPreAabb.y = selfAabb.y;
255 | otherPreAabb.y = otherAabb.y;
256 |
257 | If (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
258 | If (selfPreAabb.yMax < otherPreAabb.yMax && other.node.group == 'player') {
259 | This.todie();
260 | }
261 | }
262 | }
263 |
264 | Todie() {
265 | cc.audioEngine.play(this.dieAudio, false, 1);
266 | This.anim.play('beetled');
267 | this.canMove = false;
268 | This.node.height = this.node.height * 0.3;
269 |
270 | this.node.runAction(cc.fadeOut(.5));
271 | this.scheduleOnce(function () {
272 | this.node.removeFromParent();
273 | }, 0.5);
274 | }
275 |
276 | Update(dt) {
277 | If (this.canMove) {
278 | This.node.x -= this.speed.x * dt;
279 | }
280 | }
281 |
282 | Turn() {
283 | this.node.scaleX = -this.node.scaleX;
284 | }
285 | }
286 | ```
287 | ### Role Logic Design
288 |
289 | As the core of the game, the role's behavior design is more complicated, mainly divided into two parts: control events and collision events.
290 |
291 | #### Control event handling
292 |
293 | ```typescript
294 | onLoad() {
295 | cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
296 | cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
297 | }
298 |
299 | onDestroy() {
300 | cc.systemEvent.off(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
301 | cc.systemEvent.off(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
302 | }
303 |
304 | onKeyDown(event) {
305 | Switch (event.keyCode) {
306 | Case cc.macro.KEY.a:
307 | Case cc.macro.KEY.left:
308 | this.playerLeft();
309 | Break;
310 | Case cc.macro.KEY.d:
311 | Case cc.macro.KEY.right:
312 | this.playerRight();
313 | Break;
314 | Case cc.macro.KEY.w:
315 | Case cc.macro.KEY.up:
316 | this.playerUp();
317 | Break;
318 | Case cc.macro.KEY.down:
319 | Case cc.macro.KEY.s:
320 | this.playerDown();
321 | Break;
322 | }
323 | }
324 |
325 | onKeyUp(event) {
326 | Switch (event.keyCode) {
327 |
328 | Case cc.macro.KEY.a:
329 | Case cc.macro.KEY.left:
330 | Case cc.macro.KEY.d:
331 | Case cc.macro.KEY.right:
332 | this.noLRControlPlayer();
333 | Break;
334 | Case cc.macro.KEY.up:
335 | Case cc.macro.KEY.w:
336 | this.noUpControlPlayer();
337 | Break;
338 | Case cc.macro.KEY.s:
339 | Case cc.macro.KEY.down:
340 | this.noDownControlPlayer();
341 | Break;
342 | }
343 | }
344 | ```
345 |
346 | #### Collision event processing
347 |
348 | The object is assigned an object type tag when instantiated, and the following code assigns different collision logic based on the tag.
349 |
350 | ```typescript
351 | onCollisionEnter(other, self) {
352 | If (this.touchingNumber == 0) {
353 | If (this.buttonIsPressed)
354 | This.player_walk();
355 | Else
356 | This.player_idle();
357 | }
358 | Switch (other.tag) {
359 | Case 1://coin.tag = 1
360 | this.collisionCoinEnter(other, self);
361 | Break;
362 | Case 2://bonusblock6.tag = 2
363 | Case 3://breakableWall = 3
364 | Case 7: //bonusblock6withMushroom.tag = 7
365 | this.collisionBonusWallEnter(other, self);
366 | Break;
367 | Case 4://enemy.tag = 4
368 | this.collisionEnemyEnter(other, self);
369 | Break;
370 | Case 5://platform.tag = 5
371 | this.collisionPlatformEnter(other, self);
372 | Break;
373 | Case 6://water.tag = 6
374 | this.collisionWaterEnter(other, self);
375 | Break;
376 | Case 8://mushroom.tag = 8
377 | this.collisionMushroomEnter(other, self);
378 | Break;
379 | }
380 | }
381 | ```
382 | Collision between the character and the ground:
383 |
384 | ```typescript
385 | collisionPlatformEnter(other, self) {
386 | this.touchingNumber++;
387 | this.jumpCount = 0;
388 | Var otherAabb = other.world.aabb;
389 | Var otherPreAabb = other.world.preAabb.clone();
390 | Var selfAabb = self.world.aabb;
391 | Var selfPreAabb = self.world.preAabb.clone();
392 | selfPreAabb.x = selfAabb.x;
393 | otherPreAabb.x = otherAabb.x;
394 |
395 | If (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
396 |
397 | If (this._speed.x < 0 && (selfPreAabb.xMax > otherPreAabb.xMax)) {
398 | This.node.x += Math.floor(Math.abs(otherAabb.xMax - selfAabb.xMin));
399 | this.collisionX = -1;
400 | }
401 | Else if (this._speed.x > 0 && (selfPreAabb.xMin < otherPreAabb.xMin)) {
402 | This.node.x -= Math.floor(Math.abs(otherAabb.xMin - selfAabb.xMax));
403 | this.collisionX = 1;
404 | } else if (this._speed.x == 0 && (selfPreAabb.xMax == otherPreAabb.xMin)) {
405 | this.isFallDown = true;
406 | }
407 |
408 | This._speed.x = 0;
409 | other.touchingX = true;
410 | Return;
411 | }
412 | selfPreAabb.y = selfAabb.y;
413 | otherPreAabb.y = otherAabb.y;
414 |
415 | If (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
416 | If (this._speed.y < 0 && (selfPreAabb.yMax > otherPreAabb.yMax)) {
417 | This.node.y = otherPreAabb.yMax - this.node.parent.y;
418 | this.isJumping = false;
419 | this.collisionY = -1;
420 | }
421 | Else if (this._speed.y > 0 && (selfPreAabb.yMin < otherPreAabb.yMin)) {
422 | cc.audioEngine.play(this.hit_block_Audio, false, 1);
423 | This.node.y = otherPreAabb.yMin - selfPreAabb.height - this.node.parent.y;
424 | this.collisionY = 1;
425 | }
426 |
427 | This._speed.y = 0;
428 | other.touchingY = true;
429 | }
430 | this.isWallCollisionCount++;
431 | }
432 | ```
433 |
434 | Collision between character and enemy
435 |
436 | ```typescript
437 | collisionEnemyEnter(other, self) {
438 | // 1st step
439 | // get pre aabb, go back before collision
440 | Var otherAabb = other.world.aabb;
441 | Var otherPreAabb = other.world.preAabb.clone();
442 |
443 | Var selfAabb = self.world.aabb;
444 | Var selfPreAabb = self.world.preAabb.clone();
445 |
446 | // 2nd step
447 | // forward x-axis, check whether collision on x-axis
448 | selfPreAabb.x = selfAabb.x;
449 | otherPreAabb.x = otherAabb.x;
450 | If (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
451 | If (this._life == 2) {
452 | cc.audioEngine.play(this.player_decrease_Audio, false, 1);
453 | Var actionBy = cc.scaleBy(1, 3 / 5);
454 | this.node.runAction(actionBy);
455 | This._life--;
456 | } else if (this._life == 1) {
457 | This.anim.play("player_die");
458 | this.rabbitDieJump();
459 | this.OverNodeLoad();
460 | Return;
461 | }
462 |
463 | If (this._speed.x < 0 && (selfPreAabb.xMax > otherPreAabb.xMax)) {
464 | This.node.x += Math.floor(Math.abs(otherAabb.xMax - selfAabb.xMin));
465 | this.collisionX = -1;
466 | }
467 | Else if (this._speed.x > 0 && (selfPreAabb.xMin < otherPreAabb.xMin)) {
468 | This.node.x -= Math.floor(Math.abs(otherAabb.xMin - selfAabb.xMax));
469 | this.collisionX = 1;
470 | }
471 |
472 | This._speed.x = 0;
473 | other.touchingX = true;
474 | Return;
475 | }
476 |
477 | // 3rd step
478 | // forward y-axis, check whether collision on y-axis
479 | selfPreAabb.y = selfAabb.y;
480 | otherPreAabb.y = otherAabb.y;
481 |
482 | If (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
483 | If (this._speed.y < 0 && (selfPreAabb.yMax > otherPreAabb.yMax)) {
484 | this.rabbitJump();
485 | Return;
486 | }
487 |
488 | If (this._speed.y > 0 && (selfPreAabb.yMax < otherPreAabb.yMax)) {
489 | If (this._life == 2) {
490 | Var actionBy = cc.scaleBy(1, 3 / 5);
491 | this.node.runAction(actionBy);
492 | This._life--;
493 | } else if (this._life == 1) {
494 | This.anim.play("player_die");
495 | this.rabbitDieJump();
496 | this.OverNodeLoad();
497 | Return;
498 | }
499 | }
500 |
501 | This._speed.y = 0;
502 | other.touchingY = true;
503 | }
504 | this.isWallCollisionCount++;
505 | }
506 | ```
507 |
508 | ## At last
509 |
510 | This tutorial is mainly to explain how to use the CocosCreator editor to design a landscape game, use the creator componentization ideas, reduce the use of code, provide development efficiency, the code of this tutorial can be downloaded here [download](https: / /github.com/xianyinchen/creator_teach), resources come to the network, please do not use for commercial purposes.
--------------------------------------------------------------------------------
/Super Mario in Cocos Creator.md:
--------------------------------------------------------------------------------
1 | ## 使用CocosCreator制作超级马里奥
2 |
3 | 本教程演示如何灵活快速的使用 CocosCreator 来制作超级马里奥这款经典游戏,这个教程主要目的是帮助大家熟悉下面组件的用法,横版游戏实现方法很多,这里不做讨论哈。
4 |
5 | [TileMap](https://docs.cocos.com/creator/manual/en/asset-workflow/tiledmap.html)
6 |
7 | [Collision System](https://docs.cocos.com/creator/manual/en/physics/collision/)
8 |
9 | [Prefab](https://docs.cocos.com/creator/manual/en/asset-workflow/prefab.html)
10 |
11 | [Keyboard Event](https://docs.cocos.com/creator/manual/en/scripting/player-controls.html#keyboard-events)
12 |
13 | [Atlas](https://docs.cocos.com/creator/manual/en/asset-workflow/atlas.html)
14 |
15 | 该教程基于 Cocos Creator v2.x 版本,点击[下载](https://cocos2d-x.org/download)并安装,内容参考来至[论坛](https://forum.cocos.com/t/creator/47112)。
16 |
17 | ## 开始我们的游戏制作
18 |
19 | 先看下我们最后实现的效果(美术资源来至互联网)。
20 |
21 | ## 游戏场景设计
22 |
23 | 参考超级玛丽的世界观,我们先在[节点管理器](https://docs.cocos.com/creator/manual/en/content-workflow/node-tree.html)构建我们的世界节点树,我们添加了摄像机,游戏背景层,世界根节点,地图节点,角色节点。
24 |
25 | 
26 |
27 | ### 添加摄像机(Main Camera)
28 |
29 | 摄像机作为玩家观察游戏世界的窗口,Creator默认会自动为场景分配一个[摄像机](https://docs.cocos.com/creator/manual/en/render/camera.html) ,我们无需手动添加。
30 |
31 | ### 添加世界根节点(World Root)
32 |
33 | 添加一个空节点,用于放置游戏内的物体节点。
34 |
35 | 1. 创建脚本world.ts并拖入节点属性面板,用于配置游戏世界参数,比如设置重力加速度G的值。
36 | 2. 创建脚本lookat.ts并拖入节点属性面板,根据Player节点的位置同步世界视角。
37 |
38 | 全局配置 world.ts 代码:
39 |
40 | ```typescript
41 |
42 | const {ccclass, property} = cc._decorator;
43 |
44 | @ccclass
45 | export default class CWorld extends cc.Component {
46 |
47 | @property()
48 | WorldFallG: number = 0;
49 |
50 | @property()
51 | WorldWalkA: number = 0;
52 |
53 | static G: number = 0;
54 | static WalkA: number = 0;
55 |
56 | // LIFE-CYCLE CALLBACKS:
57 |
58 | onLoad () {
59 | CWorld.G = this.WorldFallG;
60 | CWorld.WalkA = this.WorldWalkA;
61 | }
62 |
63 | start () {
64 | // enable Collision System
65 | cc.director.getCollisionManager().enabled = true;
66 | cc.director.getCollisionManager().enabledDebugDraw = true;
67 | cc.director.getCollisionManager().enabledDrawBoundingBox = true;
68 | }
69 |
70 | // update (dt) {}
71 | }
72 | ```
73 |
74 | 世界视角控制 lookat.ts 代码:
75 |
76 | ```typescript
77 | const { ccclass, property } = cc._decorator;
78 |
79 | @ccclass
80 | export default class NewClass extends cc.Component {
81 |
82 | @property(cc.Node)
83 | target: cc.Node = null;
84 |
85 | @property(cc.Node)
86 | map: cc.Node = null;
87 |
88 | boundingBox: cc.Rect = null;
89 | screenMiddle: cc.Vec2 = null;
90 |
91 | minX: number = 0;
92 | maxX: number = 0;
93 | minY: number = 0;
94 | maxY: number = 0;
95 |
96 | isRun: boolean = true;
97 |
98 | // LIFE-CYCLE CALLBACKS:
99 |
100 | onLoad() {
101 | this.boundingBox = new cc.Rect(0, 0, this.map.width, this.map.height);
102 | let winsize = cc.winSize;
103 | this.screenMiddle = new cc.Vec2(winsize.width / 2, winsize.height / 2);
104 | this.minX = -(this.boundingBox.xMax - winsize.width);
105 | this.maxX = this.boundingBox.xMin;
106 | this.minY = -(this.boundingBox.yMax - winsize.height);
107 | this.maxY = this.boundingBox.yMin;
108 | }
109 |
110 | update() {
111 | if (!this.isRun)
112 | return;
113 |
114 | let pos = this.node.convertToWorldSpaceAR(cc.Vec2.ZERO);
115 | let targertPos = this.target.convertToWorldSpaceAR(cc.Vec2.ZERO);
116 | let dis = pos.sub(targertPos);
117 | let dest = this.screenMiddle.add(dis);
118 | dest.x = cc.misc.clampf(dest.x, this.minX, this.maxX);
119 | dest.y = this.minY;
120 | this.node.position = this.node.parent.convertToNodeSpaceAR(dest);
121 | }
122 | }
123 | ```
124 |
125 | ### 添加角色(Player)
126 |
127 | 我们控制的游戏主角节点,作为游戏世界视角的焦点。
128 |
129 | ### 添加地图(Tiled Map)
130 |
131 | 将 [Tiled](https://www.mapeditor.org/) (支持 TiledMap v1.0) 制作好的地图资源 level01,拖入到世界节点下面,自动会生成地图节点,这时候可以查看展开的TiledMap地图层级。
132 |
133 | 
134 |
135 | 根据 TiledMap 设计的物体类型,需要对物体进行实例化,我们创建waorldmap.ts脚本来完成这个工作,下图是我们已配置的地图层级和物体的Prefab资源。
136 |
137 | 
138 |
139 | 地图对象的实例化,分为几步:
140 |
141 | - 实例化类型对应的Prefab资源
142 | - 设置碰撞组
143 | - 设置物体大小
144 | - 添加碰撞组件
145 | - 设置物体的类型标签
146 |
147 | 在waorldmap.ts 中,水对象的实例化过程如下:
148 |
149 | ```typescript
150 | // get waters layer and traverse all water objects.
151 | var waters = this.worldMap.getObjectGroup(this.waterLayerName);
152 | for (var i = 1; i < 8; i++) {
153 | var waterName = 'water' + i;
154 | var waterBlock = waters.getObject(waterName);
155 | var waterNode = cc.instantiate(this.ColliderPreName);
156 |
157 | // set group name for Collider System.
158 | waterNode.group = 'water';
159 |
160 | // set size
161 | waterNode.width = waterBlock.width;
162 | waterNode.height = waterBlock.height;
163 | waterNode.x = waterBlock.x;
164 | waterNode.y = waterBlock.y - waterBlock.height;
165 |
166 | // add collider component.
167 | waterNode.addComponent(cc.BoxCollider);
168 | waterNode.getComponent(cc.BoxCollider).size = cc.size(waterNode.width, waterNode.height);
169 | waterNode.getComponent(cc.BoxCollider).offset =
170 | new cc.Vec2(waterNode.width / 2, -waterNode.height / 2);
171 |
172 | // set tag for check when collision.
173 | waterNode.getComponent(cc.BoxCollider).tag = 6;
174 | this.node.addChild(waterNode);
175 | }
176 | ```
177 |
178 | ### 添加碰撞规则
179 |
180 | 世界物体包含了角色,地面,方块,金币,甲壳虫,水,蘑菇,创建碰撞组和碰撞组来约束物体彼此之间碰撞规则。
181 |
182 | 
183 |
184 | ## 游戏物体设计
185 |
186 | 游戏物体会根据本身的特性去进行分类做成预制体,预制体根据物体特性,添加下面内容:
187 |
188 | - 碰撞特性
189 | - 动作表现
190 | - 音效表现
191 | - 行为控制脚本
192 |
193 | ### 物体Prefab制作
194 |
195 | 例如下面是甲壳虫的资源目录,包含了甲壳虫动画文件 **beetle_anim**,预制体资源 **beetle_node**,皮肤文件 **beetle_skin**,行为控制脚本 **beetle_script**。
196 |
197 | |
198 |
199 | 给甲壳虫预制体添加动作组件
200 |
201 | 
202 |
203 | 给甲壳虫预制体添加碰撞组件
204 |
205 | 
206 |
207 | 给甲壳虫预制体添加脚本组件,设置了移动速度,缩放系数,音效等属性
208 |
209 | 
210 |
211 | 下面是制作甲壳虫脚本,用于碰撞检测和行为控制
212 |
213 | ```typescript
214 | const { ccclass, property } = cc._decorator;
215 |
216 | @ccclass
217 | export default class enemy extends cc.Component {
218 | @property()
219 | speed: cc.Vec2 = new cc.Vec2(0, 0);
220 |
221 | @property
222 | scaleX: number = 1;
223 |
224 | @property
225 | canMove: boolean = true;
226 |
227 | @property({type: cc.AudioClip})
228 | dieAudio: cc.AudioClip = null;
229 |
230 | anim: cc.Animation = null;
231 |
232 | // LIFE-CYCLE CALLBACKS:
233 |
234 | onLoad() {
235 | this.node.scaleX = 1;
236 | this.anim = this.getComponent(cc.Animation);
237 | }
238 |
239 | start() {
240 |
241 | }
242 |
243 | // onCollisionEnter overrated
244 | onCollisionEnter(other, self) {
245 | if (other.tag == 5) {
246 | this.turn();
247 | this.speed.x = -this.speed.x;
248 | }
249 |
250 | var otherAabb = other.world.aabb;
251 | var otherPreAabb = other.world.preAabb.clone();
252 |
253 | var selfAabb = self.world.aabb;
254 | var selfPreAabb = self.world.preAabb.clone();
255 | selfPreAabb.y = selfAabb.y;
256 | otherPreAabb.y = otherAabb.y;
257 |
258 | if (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
259 | if (selfPreAabb.yMax < otherPreAabb.yMax && other.node.group == 'player') {
260 | this.todie();
261 | }
262 | }
263 | }
264 |
265 | todie() {
266 | cc.audioEngine.play(this.dieAudio, false, 1);
267 | this.anim.play('beetled');
268 | this.canMove = false;
269 | this.node.height = this.node.height * 0.3;
270 |
271 | this.node.runAction(cc.fadeOut(.5));
272 | this.scheduleOnce(function () {
273 | this.node.removeFromParent();
274 | }, 0.5);
275 | }
276 |
277 | update(dt) {
278 | if (this.canMove) {
279 | this.node.x -= this.speed.x * dt;
280 | }
281 | }
282 |
283 | turn() {
284 | this.node.scaleX = -this.node.scaleX;
285 | }
286 | }
287 | ```
288 |
289 | ### 角色逻辑设计
290 |
291 | 作为游戏的核心,角色的行为设计是比较复杂,主要分为控制事件和碰撞事件两部分。
292 |
293 | #### 控制事件处理
294 |
295 | ```typescript
296 | onLoad() {
297 | cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
298 | cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
299 | }
300 |
301 | onDestroy() {
302 | cc.systemEvent.off(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
303 | cc.systemEvent.off(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
304 | }
305 |
306 | onKeyDown(event) {
307 | switch (event.keyCode) {
308 | case cc.macro.KEY.a:
309 | case cc.macro.KEY.left:
310 | this.playerLeft();
311 | break;
312 | case cc.macro.KEY.d:
313 | case cc.macro.KEY.right:
314 | this.playerRight();
315 | break;
316 | case cc.macro.KEY.w:
317 | case cc.macro.KEY.up:
318 | this.playerUp();
319 | break;
320 | case cc.macro.KEY.down:
321 | case cc.macro.KEY.s:
322 | this.playerDown();
323 | break;
324 | }
325 | }
326 |
327 | onKeyUp(event) {
328 | switch (event.keyCode) {
329 |
330 | case cc.macro.KEY.a:
331 | case cc.macro.KEY.left:
332 | case cc.macro.KEY.d:
333 | case cc.macro.KEY.right:
334 | this.noLRControlPlayer();
335 | break;
336 | case cc.macro.KEY.up:
337 | case cc.macro.KEY.w:
338 | this.noUpControlPlayer();
339 | break;
340 | case cc.macro.KEY.s:
341 | case cc.macro.KEY.down:
342 | this.noDownControlPlayer();
343 | break;
344 | }
345 | }
346 | ```
347 |
348 | #### 碰撞事件处理
349 |
350 | 物体对象在实例化时候分配了物体类型标签,下面代码根据标签来指派不同的碰撞逻辑。
351 |
352 | ```typescript
353 | onCollisionEnter(other, self) {
354 | if (this.touchingNumber == 0) {
355 | if (this.buttonIsPressed)
356 | this.player_walk();
357 | else
358 | this.player_idle();
359 | }
360 | switch (other.tag) {
361 | case 1://coin.tag = 1
362 | this.collisionCoinEnter(other, self);
363 | break;
364 | case 2://bonusblock6.tag = 2
365 | case 3://breakableWall = 3
366 | case 7: //bonusblock6withMushroom.tag = 7
367 | this.collisionBonusWallEnter(other, self);
368 | break;
369 | case 4://enemy.tag = 4
370 | this.collisionEnemyEnter(other, self);
371 | break;
372 | case 5://platform.tag = 5
373 | this.collisionPlatformEnter(other, self);
374 | break;
375 | case 6://water.tag = 6
376 | this.collisionWaterEnter(other, self);
377 | break;
378 | case 8://mushroom.tag = 8
379 | this.collisionMushroomEnter(other, self);
380 | break;
381 | }
382 | }
383 | ```
384 |
385 | 角色与地面的碰撞处理:
386 |
387 | ```typescript
388 | collisionPlatformEnter(other, self) {
389 | this.touchingNumber++;
390 | this.jumpCount = 0;
391 | var otherAabb = other.world.aabb;
392 | var otherPreAabb = other.world.preAabb.clone();
393 | var selfAabb = self.world.aabb;
394 | var selfPreAabb = self.world.preAabb.clone();
395 | selfPreAabb.x = selfAabb.x;
396 | otherPreAabb.x = otherAabb.x;
397 |
398 | if (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
399 |
400 | if (this._speed.x < 0 && (selfPreAabb.xMax > otherPreAabb.xMax)) {
401 | this.node.x += Math.floor(Math.abs(otherAabb.xMax - selfAabb.xMin));
402 | this.collisionX = -1;
403 | }
404 | else if (this._speed.x > 0 && (selfPreAabb.xMin < otherPreAabb.xMin)) {
405 | this.node.x -= Math.floor(Math.abs(otherAabb.xMin - selfAabb.xMax));
406 | this.collisionX = 1;
407 | } else if (this._speed.x == 0 && (selfPreAabb.xMax == otherPreAabb.xMin)) {
408 | this.isFallDown = true;
409 | }
410 |
411 | this._speed.x = 0;
412 | other.touchingX = true;
413 | return;
414 | }
415 | selfPreAabb.y = selfAabb.y;
416 | otherPreAabb.y = otherAabb.y;
417 |
418 | if (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
419 | if (this._speed.y < 0 && (selfPreAabb.yMax > otherPreAabb.yMax)) {
420 | this.node.y = otherPreAabb.yMax - this.node.parent.y;
421 | this.isJumping = false;
422 | this.collisionY = -1;
423 | }
424 | else if (this._speed.y > 0 && (selfPreAabb.yMin < otherPreAabb.yMin)) {
425 | cc.audioEngine.play(this.hit_block_Audio, false, 1);
426 | this.node.y = otherPreAabb.yMin - selfPreAabb.height - this.node.parent.y;
427 | this.collisionY = 1;
428 | }
429 |
430 | this._speed.y = 0;
431 | other.touchingY = true;
432 | }
433 | this.isWallCollisionCount++;
434 | }
435 | ```
436 |
437 | 角色与敌人的碰撞
438 |
439 | ```typescript
440 | collisionEnemyEnter(other, self) {
441 | // 1st step
442 | // get pre aabb, go back before collision
443 | var otherAabb = other.world.aabb;
444 | var otherPreAabb = other.world.preAabb.clone();
445 |
446 | var selfAabb = self.world.aabb;
447 | var selfPreAabb = self.world.preAabb.clone();
448 |
449 | // 2nd step
450 | // forward x-axis, check whether collision on x-axis
451 | selfPreAabb.x = selfAabb.x;
452 | otherPreAabb.x = otherAabb.x;
453 | if (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
454 | if (this._life == 2) {
455 | cc.audioEngine.play(this.player_decrease_Audio, false, 1);
456 | var actionBy = cc.scaleBy(1, 3 / 5);
457 | this.node.runAction(actionBy);
458 | this._life--;
459 | } else if (this._life == 1) {
460 | this.anim.play("player_die");
461 | this.rabbitDieJump();
462 | this.OverNodeLoad();
463 | return;
464 | }
465 |
466 | if (this._speed.x < 0 && (selfPreAabb.xMax > otherPreAabb.xMax)) {
467 | this.node.x += Math.floor(Math.abs(otherAabb.xMax - selfAabb.xMin));
468 | this.collisionX = -1;
469 | }
470 | else if (this._speed.x > 0 && (selfPreAabb.xMin < otherPreAabb.xMin)) {
471 | this.node.x -= Math.floor(Math.abs(otherAabb.xMin - selfAabb.xMax));
472 | this.collisionX = 1;
473 | }
474 |
475 | this._speed.x = 0;
476 | other.touchingX = true;
477 | return;
478 | }
479 |
480 | // 3rd step
481 | // forward y-axis, check whether collision on y-axis
482 | selfPreAabb.y = selfAabb.y;
483 | otherPreAabb.y = otherAabb.y;
484 |
485 | if (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
486 | if (this._speed.y < 0 && (selfPreAabb.yMax > otherPreAabb.yMax)) {
487 | this.rabbitJump();
488 | return;
489 | }
490 |
491 | if (this._speed.y > 0 && (selfPreAabb.yMax < otherPreAabb.yMax)) {
492 | if (this._life == 2) {
493 | var actionBy = cc.scaleBy(1, 3 / 5);
494 | this.node.runAction(actionBy);
495 | this._life--;
496 | } else if (this._life == 1) {
497 | this.anim.play("player_die");
498 | this.rabbitDieJump();
499 | this.OverNodeLoad();
500 | return;
501 | }
502 | }
503 |
504 | this._speed.y = 0;
505 | other.touchingY = true;
506 | }
507 | this.isWallCollisionCount++;
508 | }
509 | ```
510 |
511 | ## 最后
512 |
513 | 本教程主要是讲解如何使用 CocosCreator 编辑器来设计一款横版的闯关游戏,运用creator的组件化思想,减少代码的使用,提供开发效率,本教程代码的可以点击这里[下载](https://github.com/xianyinchen/creator_teach),资源来至网络,请勿用于商业目的。
--------------------------------------------------------------------------------
/assets/map.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "54dd4052-a0f8-4e22-906a-b27d508c19bf",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/map/level01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/assets/map/level01.png
--------------------------------------------------------------------------------
/assets/map/level01.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.2.0",
3 | "uuid": "c3ca462f-8875-49a1-b603-cbede984066b",
4 | "type": "sprite",
5 | "wrapMode": "clamp",
6 | "filterMode": "bilinear",
7 | "premultiplyAlpha": false,
8 | "subMetas": {
9 | "level01": {
10 | "ver": "1.0.4",
11 | "uuid": "4a469fa3-0995-4236-b76d-c7e134b07567",
12 | "rawTextureUuid": "c3ca462f-8875-49a1-b603-cbede984066b",
13 | "trimType": "auto",
14 | "trimThreshold": 1,
15 | "rotated": false,
16 | "offsetX": 0,
17 | "offsetY": 0,
18 | "trimX": 0,
19 | "trimY": 0,
20 | "width": 884,
21 | "height": 476,
22 | "rawWidth": 884,
23 | "rawHeight": 476,
24 | "borderTop": 0,
25 | "borderBottom": 0,
26 | "borderLeft": 0,
27 | "borderRight": 0,
28 | "subMetas": {}
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/assets/map/level01.tmx:
--------------------------------------------------------------------------------
1 |
2 |
447 |
--------------------------------------------------------------------------------
/assets/map/level01.tmx.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.0.1",
3 | "uuid": "7a2f1842-cd7b-459f-9c64-c5d206380990",
4 | "subMetas": {}
5 | }
--------------------------------------------------------------------------------
/assets/object.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "7b3bf641-c7dc-40d1-a900-870098ac524a",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/beetle.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "26e963f4-80b3-43fe-a776-4512a6cdfbeb",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/beetle/beetle_anim.anim:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.AnimationClip",
3 | "_name": "beetle",
4 | "_objFlags": 0,
5 | "_rawFiles": null,
6 | "_duration": 1,
7 | "sample": 8,
8 | "speed": 0.8,
9 | "wrapMode": 2,
10 | "curveData": {
11 | "comps": {
12 | "cc.Sprite": {
13 | "spriteFrame": [
14 | {
15 | "frame": 0,
16 | "value": {
17 | "__uuid__": "6968d24a-3394-4b87-9ac2-7b28240a983a"
18 | }
19 | },
20 | {
21 | "frame": 0.125,
22 | "value": {
23 | "__uuid__": "607fb4d2-3da0-4ea6-9855-0636b4736875"
24 | }
25 | },
26 | {
27 | "frame": 0.25,
28 | "value": {
29 | "__uuid__": "814f53cb-96d0-46e9-8915-2d4f4fe91f29"
30 | }
31 | },
32 | {
33 | "frame": 0.375,
34 | "value": {
35 | "__uuid__": "aadb5684-ef80-4067-b0ae-9df2cca11c17"
36 | }
37 | },
38 | {
39 | "frame": 0.5,
40 | "value": {
41 | "__uuid__": "2e9189ba-5cf5-433d-9041-9cc0ec0880d2"
42 | }
43 | },
44 | {
45 | "frame": 0.625,
46 | "value": {
47 | "__uuid__": "4c36018f-85e7-489a-bc20-e5022201e041"
48 | }
49 | },
50 | {
51 | "frame": 0.75,
52 | "value": {
53 | "__uuid__": "6a990afa-d004-42c9-8699-081c221d9e50"
54 | }
55 | },
56 | {
57 | "frame": 0.875,
58 | "value": {
59 | "__uuid__": "1e01d7ec-d1c5-4fdb-96ad-03e4c85b2ece"
60 | }
61 | }
62 | ]
63 | }
64 | }
65 | },
66 | "events": []
67 | }
--------------------------------------------------------------------------------
/assets/object/beetle/beetle_anim.anim.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.0",
3 | "uuid": "5a09bc5a-e5cc-48d6-b40d-5d5eee95616b",
4 | "subMetas": {}
5 | }
--------------------------------------------------------------------------------
/assets/object/beetle/beetle_anim2.anim:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.AnimationClip",
3 | "_name": "beetled",
4 | "_objFlags": 0,
5 | "_rawFiles": null,
6 | "_duration": 0.016666666666666666,
7 | "sample": 60,
8 | "speed": 1,
9 | "wrapMode": 1,
10 | "curveData": {
11 | "comps": {
12 | "cc.Sprite": {
13 | "spriteFrame": [
14 | {
15 | "frame": 0,
16 | "value": {
17 | "__uuid__": "4d511f12-8e15-4a54-b7ef-a24121a5e3a8"
18 | }
19 | }
20 | ]
21 | }
22 | }
23 | },
24 | "events": []
25 | }
--------------------------------------------------------------------------------
/assets/object/beetle/beetle_anim2.anim.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.0",
3 | "uuid": "4ee7dd22-07d4-4c13-8e39-dc45d04ccd30",
4 | "subMetas": {}
5 | }
--------------------------------------------------------------------------------
/assets/object/beetle/beetle_node.prefab:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.Prefab",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "data": {
8 | "__id__": 1
9 | },
10 | "optimizationPolicy": 0,
11 | "asyncLoadAssets": false
12 | },
13 | {
14 | "__type__": "cc.Node",
15 | "_name": "beetle_node",
16 | "_objFlags": 0,
17 | "_parent": null,
18 | "_children": [],
19 | "_active": true,
20 | "_level": 1,
21 | "_components": [
22 | {
23 | "__id__": 2
24 | },
25 | {
26 | "__id__": 3
27 | },
28 | {
29 | "__id__": 4
30 | },
31 | {
32 | "__id__": 5
33 | }
34 | ],
35 | "_prefab": {
36 | "__id__": 6
37 | },
38 | "_opacity": 255,
39 | "_color": {
40 | "__type__": "cc.Color",
41 | "r": 255,
42 | "g": 255,
43 | "b": 255,
44 | "a": 255
45 | },
46 | "_contentSize": {
47 | "__type__": "cc.Size",
48 | "width": 50,
49 | "height": 50
50 | },
51 | "_anchorPoint": {
52 | "__type__": "cc.Vec2",
53 | "x": 0.5,
54 | "y": 0.5
55 | },
56 | "_position": {
57 | "__type__": "cc.Vec3",
58 | "x": 199,
59 | "y": 141,
60 | "z": 0
61 | },
62 | "_scale": {
63 | "__type__": "cc.Vec3",
64 | "x": 1,
65 | "y": 1,
66 | "z": 1
67 | },
68 | "_rotationX": 0,
69 | "_rotationY": 0,
70 | "_quat": {
71 | "__type__": "cc.Quat",
72 | "x": 0,
73 | "y": 0,
74 | "z": 0,
75 | "w": 1
76 | },
77 | "_skewX": 0,
78 | "_skewY": 0,
79 | "groupIndex": 5,
80 | "_id": ""
81 | },
82 | {
83 | "__type__": "cc.Sprite",
84 | "_name": "",
85 | "_objFlags": 0,
86 | "node": {
87 | "__id__": 1
88 | },
89 | "_enabled": true,
90 | "_srcBlendFactor": 770,
91 | "_dstBlendFactor": 771,
92 | "_spriteFrame": {
93 | "__uuid__": "6968d24a-3394-4b87-9ac2-7b28240a983a"
94 | },
95 | "_type": 0,
96 | "_sizeMode": 0,
97 | "_fillType": 0,
98 | "_fillCenter": {
99 | "__type__": "cc.Vec2",
100 | "x": 0,
101 | "y": 0
102 | },
103 | "_fillStart": 0,
104 | "_fillRange": 0,
105 | "_isTrimmedMode": true,
106 | "_state": 0,
107 | "_atlas": {
108 | "__uuid__": "5b2132c2-3273-4db9-90a9-3b17949ee8e1"
109 | },
110 | "_id": ""
111 | },
112 | {
113 | "__type__": "cc.Animation",
114 | "_name": "",
115 | "_objFlags": 0,
116 | "node": {
117 | "__id__": 1
118 | },
119 | "_enabled": true,
120 | "_defaultClip": {
121 | "__uuid__": "5a09bc5a-e5cc-48d6-b40d-5d5eee95616b"
122 | },
123 | "_clips": [
124 | {
125 | "__uuid__": "5a09bc5a-e5cc-48d6-b40d-5d5eee95616b"
126 | },
127 | {
128 | "__uuid__": "4ee7dd22-07d4-4c13-8e39-dc45d04ccd30"
129 | }
130 | ],
131 | "playOnLoad": true,
132 | "_id": ""
133 | },
134 | {
135 | "__type__": "cc.BoxCollider",
136 | "_name": "",
137 | "_objFlags": 0,
138 | "node": {
139 | "__id__": 1
140 | },
141 | "_enabled": true,
142 | "tag": 4,
143 | "_offset": {
144 | "__type__": "cc.Vec2",
145 | "x": 0,
146 | "y": 0
147 | },
148 | "_size": {
149 | "__type__": "cc.Size",
150 | "width": 50,
151 | "height": 50
152 | },
153 | "_id": ""
154 | },
155 | {
156 | "__type__": "81eacsNH+VFVoYC5c5a60LE",
157 | "_name": "",
158 | "_objFlags": 0,
159 | "node": {
160 | "__id__": 1
161 | },
162 | "_enabled": true,
163 | "speed": {
164 | "__type__": "cc.Vec2",
165 | "x": 100,
166 | "y": 0
167 | },
168 | "scaleX": 1,
169 | "canMove": true,
170 | "dieAudio": {
171 | "__uuid__": "6a2d22ca-e6d1-4207-8452-2ba2e5a43495"
172 | },
173 | "_id": ""
174 | },
175 | {
176 | "__type__": "cc.PrefabInfo",
177 | "root": {
178 | "__id__": 1
179 | },
180 | "asset": {
181 | "__uuid__": "7a9ef0b6-c82f-4277-bca3-31ca3cdea755"
182 | },
183 | "fileId": "ccXwC8ORhEQosxiSrlTmS/",
184 | "sync": false
185 | }
186 | ]
--------------------------------------------------------------------------------
/assets/object/beetle/beetle_node.prefab.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "7a9ef0b6-c82f-4277-bca3-31ca3cdea755",
4 | "optimizationPolicy": "AUTO",
5 | "asyncLoadAssets": false,
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/beetle/beetle_script.ts:
--------------------------------------------------------------------------------
1 | // Learn TypeScript:
2 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
3 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
4 | // Learn Attribute:
5 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
6 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
7 | // Learn life-cycle callbacks:
8 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
9 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
10 |
11 | const { ccclass, property } = cc._decorator;
12 |
13 | @ccclass
14 | export default class enemy extends cc.Component {
15 |
16 | @property()
17 | speed: cc.Vec2 = new cc.Vec2(0, 0);
18 |
19 | @property
20 | scaleX: number = 1;
21 |
22 | @property
23 | canMove: boolean = true;
24 |
25 | @property({ type: cc.AudioClip })
26 | dieAudio: cc.AudioClip = null;
27 |
28 | anim: cc.Animation = null;
29 |
30 | // LIFE-CYCLE CALLBACKS:
31 |
32 | onLoad() {
33 | this.node.scaleX = 1;
34 | this.anim = this.getComponent(cc.Animation);
35 | }
36 |
37 | start() {
38 |
39 | }
40 |
41 | onCollisionEnter(other, self) {
42 | if (other.tag == 5) {
43 | this.turn();
44 | this.speed.x = -this.speed.x;
45 | }
46 |
47 | var otherAabb = other.world.aabb;
48 | var otherPreAabb = other.world.preAabb.clone();
49 |
50 | var selfAabb = self.world.aabb;
51 | var selfPreAabb = self.world.preAabb.clone();
52 | selfPreAabb.y = selfAabb.y;
53 | otherPreAabb.y = otherAabb.y;
54 |
55 | if (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
56 | if (selfPreAabb.yMax < otherPreAabb.yMax && other.node.group == 'player') {
57 | this.todie();
58 | }
59 | }
60 | }
61 |
62 | todie() {
63 | //cc.audioEngine.play(this.dieAudio, false, Global.volume);
64 | this.anim.play('beetled');
65 | this.canMove = false;
66 | this.node.height = this.node.height * 0.3;
67 | // this.node.y = 0.5*this.node.y;
68 | // var action = cc.fadeOut(1.0);
69 | this.node.runAction(cc.fadeOut(.5));
70 |
71 | this.scheduleOnce(function () {
72 | // 这里的 this 指向 component
73 | this.node.removeFromParent();
74 | }, 0.5);
75 | }
76 |
77 | update(dt) {
78 | if (this.canMove) {
79 | this.node.x -= this.speed.x * dt;
80 | }
81 | }
82 |
83 | turn() {
84 | // this.speedX = -100;
85 | this.node.scaleX = -this.node.scaleX;
86 | }
87 |
88 | // update (dt) {}
89 | }
90 |
--------------------------------------------------------------------------------
/assets/object/beetle/beetle_script.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "81eacb0d-1fe5-4556-8602-e5ce5aeb42c4",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/object/beetle/beetle_skin.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | frames
6 |
7 | beetle_01.png
8 |
9 | aliases
10 |
11 | spriteOffset
12 | {0,0}
13 | spriteSize
14 | {72,50}
15 | spriteSourceSize
16 | {72,50}
17 | textureRect
18 | {{1,1},{72,50}}
19 | textureRotated
20 |
21 |
22 | beetle_02.png
23 |
24 | aliases
25 |
26 | spriteOffset
27 | {0,0}
28 | spriteSize
29 | {72,50}
30 | spriteSourceSize
31 | {72,50}
32 | textureRect
33 | {{1,1},{72,50}}
34 | textureRotated
35 |
36 |
37 | beetle_03.png
38 |
39 | aliases
40 |
41 | spriteOffset
42 | {0,0}
43 | spriteSize
44 | {70,46}
45 | spriteSourceSize
46 | {70,46}
47 | textureRect
48 | {{75,73},{70,46}}
49 | textureRotated
50 |
51 |
52 | beetle_04.png
53 |
54 | aliases
55 |
56 | spriteOffset
57 | {0,0}
58 | spriteSize
59 | {70,46}
60 | spriteSourceSize
61 | {70,46}
62 | textureRect
63 | {{75,73},{70,46}}
64 | textureRotated
65 |
66 |
67 | beetle_05.png
68 |
69 | aliases
70 |
71 | spriteOffset
72 | {0,0}
73 | spriteSize
74 | {72,50}
75 | spriteSourceSize
76 | {72,50}
77 | textureRect
78 | {{1,53},{72,50}}
79 | textureRotated
80 |
81 |
82 | beetle_06.png
83 |
84 | aliases
85 |
86 | spriteOffset
87 | {0,0}
88 | spriteSize
89 | {72,50}
90 | spriteSourceSize
91 | {72,50}
92 | textureRect
93 | {{1,53},{72,50}}
94 | textureRotated
95 |
96 |
97 | beetle_07.png
98 |
99 | aliases
100 |
101 | spriteOffset
102 | {0,0}
103 | spriteSize
104 | {70,47}
105 | spriteSourceSize
106 | {70,47}
107 | textureRect
108 | {{75,1},{70,47}}
109 | textureRotated
110 |
111 |
112 | beetle_08.png
113 |
114 | aliases
115 |
116 | spriteOffset
117 | {0,0}
118 | spriteSize
119 | {70,47}
120 | spriteSourceSize
121 | {70,47}
122 | textureRect
123 | {{75,1},{70,47}}
124 | textureRotated
125 |
126 |
127 | beetle_09.png
128 |
129 | aliases
130 |
131 | spriteOffset
132 | {0,0}
133 | spriteSize
134 | {70,23}
135 | spriteSourceSize
136 | {70,23}
137 | textureRect
138 | {{1,105},{70,23}}
139 | textureRotated
140 |
141 |
142 |
143 | metadata
144 |
145 | format
146 | 3
147 | pixelFormat
148 | RGBA8888
149 | premultiplyAlpha
150 |
151 | realTextureFileName
152 | beetle_skin.png
153 | size
154 | {123,144}
155 | smartupdate
156 | $TexturePacker:SmartUpdate:d266eeddbacc5a40ebc81f0f3ad64b2a:2d5cf3c710b775fd520d71e2ff327123:6dbd2547e501ab173b78dd7361c38a46$
157 | textureFileName
158 | beetle_skin.png
159 |
160 |
161 |
162 |
--------------------------------------------------------------------------------
/assets/object/beetle/beetle_skin.plist.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.2.4",
3 | "uuid": "5b2132c2-3273-4db9-90a9-3b17949ee8e1",
4 | "rawTextureUuid": "77623e32-483e-4512-9589-a4b76d06a730",
5 | "size": {
6 | "width": 123,
7 | "height": 144
8 | },
9 | "type": "Texture Packer",
10 | "subMetas": {
11 | "beetle_01.png": {
12 | "ver": "1.0.4",
13 | "uuid": "6968d24a-3394-4b87-9ac2-7b28240a983a",
14 | "rawTextureUuid": "77623e32-483e-4512-9589-a4b76d06a730",
15 | "trimType": "auto",
16 | "trimThreshold": 1,
17 | "rotated": false,
18 | "offsetX": 0,
19 | "offsetY": 0,
20 | "trimX": 1,
21 | "trimY": 1,
22 | "width": 72,
23 | "height": 50,
24 | "rawWidth": 72,
25 | "rawHeight": 50,
26 | "borderTop": 0,
27 | "borderBottom": 0,
28 | "borderLeft": 0,
29 | "borderRight": 0,
30 | "spriteType": "normal",
31 | "subMetas": {}
32 | },
33 | "beetle_02.png": {
34 | "ver": "1.0.4",
35 | "uuid": "607fb4d2-3da0-4ea6-9855-0636b4736875",
36 | "rawTextureUuid": "77623e32-483e-4512-9589-a4b76d06a730",
37 | "trimType": "auto",
38 | "trimThreshold": 1,
39 | "rotated": false,
40 | "offsetX": 0,
41 | "offsetY": 0,
42 | "trimX": 1,
43 | "trimY": 1,
44 | "width": 72,
45 | "height": 50,
46 | "rawWidth": 72,
47 | "rawHeight": 50,
48 | "borderTop": 0,
49 | "borderBottom": 0,
50 | "borderLeft": 0,
51 | "borderRight": 0,
52 | "spriteType": "normal",
53 | "subMetas": {}
54 | },
55 | "beetle_03.png": {
56 | "ver": "1.0.4",
57 | "uuid": "814f53cb-96d0-46e9-8915-2d4f4fe91f29",
58 | "rawTextureUuid": "77623e32-483e-4512-9589-a4b76d06a730",
59 | "trimType": "auto",
60 | "trimThreshold": 1,
61 | "rotated": true,
62 | "offsetX": 0,
63 | "offsetY": 0,
64 | "trimX": 75,
65 | "trimY": 73,
66 | "width": 70,
67 | "height": 46,
68 | "rawWidth": 70,
69 | "rawHeight": 46,
70 | "borderTop": 0,
71 | "borderBottom": 0,
72 | "borderLeft": 0,
73 | "borderRight": 0,
74 | "spriteType": "normal",
75 | "subMetas": {}
76 | },
77 | "beetle_04.png": {
78 | "ver": "1.0.4",
79 | "uuid": "aadb5684-ef80-4067-b0ae-9df2cca11c17",
80 | "rawTextureUuid": "77623e32-483e-4512-9589-a4b76d06a730",
81 | "trimType": "auto",
82 | "trimThreshold": 1,
83 | "rotated": true,
84 | "offsetX": 0,
85 | "offsetY": 0,
86 | "trimX": 75,
87 | "trimY": 73,
88 | "width": 70,
89 | "height": 46,
90 | "rawWidth": 70,
91 | "rawHeight": 46,
92 | "borderTop": 0,
93 | "borderBottom": 0,
94 | "borderLeft": 0,
95 | "borderRight": 0,
96 | "spriteType": "normal",
97 | "subMetas": {}
98 | },
99 | "beetle_05.png": {
100 | "ver": "1.0.4",
101 | "uuid": "2e9189ba-5cf5-433d-9041-9cc0ec0880d2",
102 | "rawTextureUuid": "77623e32-483e-4512-9589-a4b76d06a730",
103 | "trimType": "auto",
104 | "trimThreshold": 1,
105 | "rotated": false,
106 | "offsetX": 0,
107 | "offsetY": 0,
108 | "trimX": 1,
109 | "trimY": 53,
110 | "width": 72,
111 | "height": 50,
112 | "rawWidth": 72,
113 | "rawHeight": 50,
114 | "borderTop": 0,
115 | "borderBottom": 0,
116 | "borderLeft": 0,
117 | "borderRight": 0,
118 | "spriteType": "normal",
119 | "subMetas": {}
120 | },
121 | "beetle_06.png": {
122 | "ver": "1.0.4",
123 | "uuid": "4c36018f-85e7-489a-bc20-e5022201e041",
124 | "rawTextureUuid": "77623e32-483e-4512-9589-a4b76d06a730",
125 | "trimType": "auto",
126 | "trimThreshold": 1,
127 | "rotated": false,
128 | "offsetX": 0,
129 | "offsetY": 0,
130 | "trimX": 1,
131 | "trimY": 53,
132 | "width": 72,
133 | "height": 50,
134 | "rawWidth": 72,
135 | "rawHeight": 50,
136 | "borderTop": 0,
137 | "borderBottom": 0,
138 | "borderLeft": 0,
139 | "borderRight": 0,
140 | "spriteType": "normal",
141 | "subMetas": {}
142 | },
143 | "beetle_07.png": {
144 | "ver": "1.0.4",
145 | "uuid": "6a990afa-d004-42c9-8699-081c221d9e50",
146 | "rawTextureUuid": "77623e32-483e-4512-9589-a4b76d06a730",
147 | "trimType": "auto",
148 | "trimThreshold": 1,
149 | "rotated": true,
150 | "offsetX": 0,
151 | "offsetY": 0,
152 | "trimX": 75,
153 | "trimY": 1,
154 | "width": 70,
155 | "height": 47,
156 | "rawWidth": 70,
157 | "rawHeight": 47,
158 | "borderTop": 0,
159 | "borderBottom": 0,
160 | "borderLeft": 0,
161 | "borderRight": 0,
162 | "spriteType": "normal",
163 | "subMetas": {}
164 | },
165 | "beetle_08.png": {
166 | "ver": "1.0.4",
167 | "uuid": "1e01d7ec-d1c5-4fdb-96ad-03e4c85b2ece",
168 | "rawTextureUuid": "77623e32-483e-4512-9589-a4b76d06a730",
169 | "trimType": "auto",
170 | "trimThreshold": 1,
171 | "rotated": true,
172 | "offsetX": 0,
173 | "offsetY": 0,
174 | "trimX": 75,
175 | "trimY": 1,
176 | "width": 70,
177 | "height": 47,
178 | "rawWidth": 70,
179 | "rawHeight": 47,
180 | "borderTop": 0,
181 | "borderBottom": 0,
182 | "borderLeft": 0,
183 | "borderRight": 0,
184 | "spriteType": "normal",
185 | "subMetas": {}
186 | },
187 | "beetle_09.png": {
188 | "ver": "1.0.4",
189 | "uuid": "4d511f12-8e15-4a54-b7ef-a24121a5e3a8",
190 | "rawTextureUuid": "77623e32-483e-4512-9589-a4b76d06a730",
191 | "trimType": "auto",
192 | "trimThreshold": 1,
193 | "rotated": false,
194 | "offsetX": 0,
195 | "offsetY": 0,
196 | "trimX": 1,
197 | "trimY": 105,
198 | "width": 70,
199 | "height": 23,
200 | "rawWidth": 70,
201 | "rawHeight": 23,
202 | "borderTop": 0,
203 | "borderBottom": 0,
204 | "borderLeft": 0,
205 | "borderRight": 0,
206 | "spriteType": "normal",
207 | "subMetas": {}
208 | }
209 | }
210 | }
--------------------------------------------------------------------------------
/assets/object/beetle/beetle_skin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/assets/object/beetle/beetle_skin.png
--------------------------------------------------------------------------------
/assets/object/beetle/beetle_skin.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.2.0",
3 | "uuid": "77623e32-483e-4512-9589-a4b76d06a730",
4 | "type": "sprite",
5 | "wrapMode": "clamp",
6 | "filterMode": "bilinear",
7 | "premultiplyAlpha": false,
8 | "subMetas": {
9 | "beetle_skin": {
10 | "ver": "1.0.4",
11 | "uuid": "a71bfca4-e491-4f9c-9416-1d508b9dc474",
12 | "rawTextureUuid": "77623e32-483e-4512-9589-a4b76d06a730",
13 | "trimType": "auto",
14 | "trimThreshold": 1,
15 | "rotated": false,
16 | "offsetX": 0,
17 | "offsetY": 0,
18 | "trimX": 0,
19 | "trimY": 0,
20 | "width": 123,
21 | "height": 144,
22 | "rawWidth": 123,
23 | "rawHeight": 144,
24 | "borderTop": 0,
25 | "borderBottom": 0,
26 | "borderLeft": 0,
27 | "borderRight": 0,
28 | "subMetas": {}
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/assets/object/block.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "2573c064-9902-4d9d-b6d4-5f70e6ebe264",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/block/block_anim.anim:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.AnimationClip",
3 | "_name": "bonusBlock",
4 | "_objFlags": 0,
5 | "_rawFiles": null,
6 | "_duration": 1,
7 | "sample": 5,
8 | "speed": 0.8,
9 | "wrapMode": 2,
10 | "curveData": {
11 | "comps": {
12 | "cc.Sprite": {
13 | "spriteFrame": [
14 | {
15 | "frame": 0,
16 | "value": {
17 | "__uuid__": "cb898fda-948d-4c00-a8ed-c1091ca944e4"
18 | }
19 | },
20 | {
21 | "frame": 0.2,
22 | "value": {
23 | "__uuid__": "32df3261-d4c2-4a8d-b006-dfe8fd6c0d59"
24 | }
25 | },
26 | {
27 | "frame": 0.4,
28 | "value": {
29 | "__uuid__": "e0a06f57-7189-4ad9-b778-bc3ff97d1097"
30 | }
31 | },
32 | {
33 | "frame": 0.6,
34 | "value": {
35 | "__uuid__": "c3340fd8-c246-4884-b577-63e98413ce1e"
36 | }
37 | },
38 | {
39 | "frame": 0.8,
40 | "value": {
41 | "__uuid__": "3b4164eb-e0ce-400d-a495-9f0f320c2d03"
42 | }
43 | }
44 | ]
45 | }
46 | }
47 | },
48 | "events": []
49 | }
--------------------------------------------------------------------------------
/assets/object/block/block_anim.anim.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.0",
3 | "uuid": "225c5e4d-4931-450a-867e-5322ef9e754e",
4 | "subMetas": {}
5 | }
--------------------------------------------------------------------------------
/assets/object/block/block_anim2.anim:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.AnimationClip",
3 | "_name": "bonusBlocked",
4 | "_objFlags": 0,
5 | "_rawFiles": null,
6 | "_duration": 0.1,
7 | "sample": 10,
8 | "speed": 1,
9 | "wrapMode": 1,
10 | "curveData": {
11 | "comps": {
12 | "cc.Sprite": {
13 | "spriteFrame": [
14 | {
15 | "frame": 0,
16 | "value": {
17 | "__uuid__": "2f5d8089-61f4-4b81-902c-3a931be792b8"
18 | }
19 | }
20 | ]
21 | }
22 | }
23 | },
24 | "events": []
25 | }
--------------------------------------------------------------------------------
/assets/object/block/block_anim2.anim.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.0",
3 | "uuid": "e5d48b56-157c-46d2-bf5c-374081c1b0c3",
4 | "subMetas": {}
5 | }
--------------------------------------------------------------------------------
/assets/object/block/block_node.prefab:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.Prefab",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "data": {
8 | "__id__": 1
9 | },
10 | "optimizationPolicy": 0,
11 | "asyncLoadAssets": false
12 | },
13 | {
14 | "__type__": "cc.Node",
15 | "_name": "bonusblock6",
16 | "_objFlags": 0,
17 | "_parent": null,
18 | "_children": [],
19 | "_active": true,
20 | "_level": 1,
21 | "_components": [
22 | {
23 | "__id__": 2
24 | },
25 | {
26 | "__id__": 3
27 | },
28 | {
29 | "__id__": 4
30 | },
31 | {
32 | "__id__": 5
33 | }
34 | ],
35 | "_prefab": {
36 | "__id__": 6
37 | },
38 | "_opacity": 255,
39 | "_color": {
40 | "__type__": "cc.Color",
41 | "r": 255,
42 | "g": 255,
43 | "b": 255,
44 | "a": 255
45 | },
46 | "_contentSize": {
47 | "__type__": "cc.Size",
48 | "width": 65,
49 | "height": 65
50 | },
51 | "_anchorPoint": {
52 | "__type__": "cc.Vec2",
53 | "x": 0.5,
54 | "y": 0.5
55 | },
56 | "_position": {
57 | "__type__": "cc.Vec3",
58 | "x": 0,
59 | "y": 0,
60 | "z": 0
61 | },
62 | "_scale": {
63 | "__type__": "cc.Vec3",
64 | "x": 1,
65 | "y": 1,
66 | "z": 1
67 | },
68 | "_rotationX": 0,
69 | "_rotationY": 0,
70 | "_quat": {
71 | "__type__": "cc.Quat",
72 | "x": 0,
73 | "y": 0,
74 | "z": 0,
75 | "w": 1
76 | },
77 | "_skewX": 0,
78 | "_skewY": 0,
79 | "groupIndex": 2,
80 | "_id": ""
81 | },
82 | {
83 | "__type__": "cc.Sprite",
84 | "_name": "",
85 | "_objFlags": 0,
86 | "node": {
87 | "__id__": 1
88 | },
89 | "_enabled": true,
90 | "_srcBlendFactor": 770,
91 | "_dstBlendFactor": 771,
92 | "_spriteFrame": {
93 | "__uuid__": "3bdc6a63-9b4f-44dc-9791-c3045ae2cc61"
94 | },
95 | "_type": 0,
96 | "_sizeMode": 0,
97 | "_fillType": 0,
98 | "_fillCenter": {
99 | "__type__": "cc.Vec2",
100 | "x": 0,
101 | "y": 0
102 | },
103 | "_fillStart": 0,
104 | "_fillRange": 0,
105 | "_isTrimmedMode": true,
106 | "_state": 0,
107 | "_atlas": null,
108 | "_id": ""
109 | },
110 | {
111 | "__type__": "cc.BoxCollider",
112 | "_name": "",
113 | "_objFlags": 0,
114 | "node": {
115 | "__id__": 1
116 | },
117 | "_enabled": true,
118 | "tag": 2,
119 | "_offset": {
120 | "__type__": "cc.Vec2",
121 | "x": 0,
122 | "y": 0
123 | },
124 | "_size": {
125 | "__type__": "cc.Size",
126 | "width": 65,
127 | "height": 65
128 | },
129 | "_id": ""
130 | },
131 | {
132 | "__type__": "cc.Animation",
133 | "_name": "",
134 | "_objFlags": 0,
135 | "node": {
136 | "__id__": 1
137 | },
138 | "_enabled": true,
139 | "_defaultClip": null,
140 | "_clips": [
141 | null,
142 | null
143 | ],
144 | "playOnLoad": true,
145 | "_id": ""
146 | },
147 | {
148 | "__type__": "f14a0DxgXtGX64eBzym58v0",
149 | "_name": "",
150 | "_objFlags": 0,
151 | "node": {
152 | "__id__": 1
153 | },
154 | "_enabled": true,
155 | "CoinJump": {
156 | "__uuid__": "f0a27f46-5b77-4fce-8986-70a1268c268e"
157 | },
158 | "mushroom": {
159 | "__uuid__": "d67a786a-3613-470f-824e-6aa547e0af00"
160 | },
161 | "isCollisionable": true,
162 | "_id": ""
163 | },
164 | {
165 | "__type__": "cc.PrefabInfo",
166 | "root": {
167 | "__id__": 1
168 | },
169 | "asset": {
170 | "__uuid__": "aee8e163-5a4d-49d2-8bf3-a2f9363ce33f"
171 | },
172 | "fileId": "83UhMReUNB2JFQpf7JiEFL",
173 | "sync": false
174 | }
175 | ]
--------------------------------------------------------------------------------
/assets/object/block/block_node.prefab.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "aee8e163-5a4d-49d2-8bf3-a2f9363ce33f",
4 | "optimizationPolicy": "AUTO",
5 | "asyncLoadAssets": false,
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/block/block_script.ts:
--------------------------------------------------------------------------------
1 | // Learn TypeScript:
2 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
3 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
4 | // Learn Attribute:
5 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
6 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
7 | // Learn life-cycle callbacks:
8 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
9 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
10 |
11 | const { ccclass, property } = cc._decorator;
12 |
13 | @ccclass
14 | export default class NewClass extends cc.Component {
15 |
16 | @property(cc.Prefab)
17 | CoinJump: cc.Prefab = null;
18 |
19 | @property(cc.Prefab)
20 | mushroom: cc.Prefab = null;
21 |
22 | @property()
23 | isCollisionable: boolean = true;
24 |
25 | anim: cc.Animation = null;
26 |
27 | // LIFE-CYCLE CALLBACKS:
28 |
29 | onLoad() {
30 | this.anim = this.getComponent(cc.Animation);
31 | this.node.scaleX = 1;
32 | this.node.zIndex = 1;
33 | // this.Score = this.ScoreBar.getComponent('Score');
34 | }
35 |
36 | start() {
37 |
38 | }
39 |
40 | onCollisionEnter(other, self) {
41 | var otherAabb = other.world.aabb;
42 | var otherPreAabb = other.world.preAabb.clone();
43 |
44 | var selfAabb = self.world.aabb;
45 | var selfPreAabb = self.world.preAabb.clone();
46 | selfPreAabb.y = selfAabb.y;
47 | otherPreAabb.y = otherAabb.y;
48 |
49 | if (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
50 |
51 | if (selfPreAabb.yMin > otherPreAabb.yMin) {
52 |
53 | if (this.isCollisionable) {
54 | if (self.tag == 7)//mushroom
55 | {
56 | var bonus = cc.instantiate(this.mushroom);
57 | }
58 | else {
59 | //Global.isGotCoin = true;
60 | var bonus = cc.instantiate(this.CoinJump);
61 | }
62 |
63 | bonus.position = this.node.parent.convertToNodeSpace(new cc.Vec2(selfAabb.x + 30, selfAabb.y + 30));
64 | this.node.parent.addChild(bonus);
65 | this.isCollisionable = false;
66 | }
67 |
68 | this.anim.play('bonusBlocked');
69 | }
70 | }
71 | }
72 |
73 | // update (dt) {}
74 | }
75 |
--------------------------------------------------------------------------------
/assets/object/block/block_script.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "f14a00f1-817b-465f-ae1e-073ca6e7cbf4",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/object/castle.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "34becae5-1f49-497c-8817-0b3f7914566a",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/castle/castle_node.prefab:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.Prefab",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "data": {
8 | "__id__": 1
9 | },
10 | "optimizationPolicy": 0,
11 | "asyncLoadAssets": false
12 | },
13 | {
14 | "__type__": "cc.Node",
15 | "_name": "castle_node",
16 | "_objFlags": 0,
17 | "_parent": null,
18 | "_children": [],
19 | "_active": true,
20 | "_level": 1,
21 | "_components": [
22 | {
23 | "__id__": 2
24 | },
25 | {
26 | "__id__": 3
27 | },
28 | {
29 | "__id__": 4
30 | }
31 | ],
32 | "_prefab": {
33 | "__id__": 5
34 | },
35 | "_opacity": 255,
36 | "_color": {
37 | "__type__": "cc.Color",
38 | "r": 255,
39 | "g": 255,
40 | "b": 255,
41 | "a": 255
42 | },
43 | "_contentSize": {
44 | "__type__": "cc.Size",
45 | "width": 314,
46 | "height": 413
47 | },
48 | "_anchorPoint": {
49 | "__type__": "cc.Vec2",
50 | "x": 0.5,
51 | "y": 0.5
52 | },
53 | "_position": {
54 | "__type__": "cc.Vec3",
55 | "x": 189,
56 | "y": 334,
57 | "z": 0
58 | },
59 | "_scale": {
60 | "__type__": "cc.Vec3",
61 | "x": 1,
62 | "y": 1,
63 | "z": 1
64 | },
65 | "_rotationX": 0,
66 | "_rotationY": 0,
67 | "_quat": {
68 | "__type__": "cc.Quat",
69 | "x": 0,
70 | "y": 0,
71 | "z": 0,
72 | "w": 1
73 | },
74 | "_skewX": 0,
75 | "_skewY": 0,
76 | "groupIndex": 2,
77 | "_id": ""
78 | },
79 | {
80 | "__type__": "cc.Sprite",
81 | "_name": "",
82 | "_objFlags": 0,
83 | "node": {
84 | "__id__": 1
85 | },
86 | "_enabled": true,
87 | "_srcBlendFactor": 770,
88 | "_dstBlendFactor": 771,
89 | "_spriteFrame": {
90 | "__uuid__": "4165521b-f075-4980-845a-0a758ce2f4a6"
91 | },
92 | "_type": 0,
93 | "_sizeMode": 1,
94 | "_fillType": 0,
95 | "_fillCenter": {
96 | "__type__": "cc.Vec2",
97 | "x": 0,
98 | "y": 0
99 | },
100 | "_fillStart": 0,
101 | "_fillRange": 0,
102 | "_isTrimmedMode": true,
103 | "_state": 0,
104 | "_atlas": null,
105 | "_id": ""
106 | },
107 | {
108 | "__type__": "cc.BoxCollider",
109 | "_name": "",
110 | "_objFlags": 0,
111 | "node": {
112 | "__id__": 1
113 | },
114 | "_enabled": true,
115 | "tag": 0,
116 | "_offset": {
117 | "__type__": "cc.Vec2",
118 | "x": -2,
119 | "y": -160
120 | },
121 | "_size": {
122 | "__type__": "cc.Size",
123 | "width": 56,
124 | "height": 90
125 | },
126 | "_id": ""
127 | },
128 | {
129 | "__type__": "20ac2GjQDVPuLDS2+81uxN3",
130 | "_name": "",
131 | "_objFlags": 0,
132 | "node": {
133 | "__id__": 1
134 | },
135 | "_enabled": true,
136 | "high_score_Audio": null,
137 | "_id": ""
138 | },
139 | {
140 | "__type__": "cc.PrefabInfo",
141 | "root": {
142 | "__id__": 1
143 | },
144 | "asset": {
145 | "__uuid__": "cf56cc98-c54f-43df-bcce-88b38db546c0"
146 | },
147 | "fileId": "84PpmNGd5OvbQ9ntou0CH0",
148 | "sync": false
149 | }
150 | ]
--------------------------------------------------------------------------------
/assets/object/castle/castle_node.prefab.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "cf56cc98-c54f-43df-bcce-88b38db546c0",
4 | "optimizationPolicy": "AUTO",
5 | "asyncLoadAssets": false,
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/castle/castle_script.ts:
--------------------------------------------------------------------------------
1 | // Learn TypeScript:
2 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
3 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
4 | // Learn Attribute:
5 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
6 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
7 | // Learn life-cycle callbacks:
8 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
9 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
10 |
11 | const { ccclass, property } = cc._decorator;
12 |
13 | @ccclass
14 | export default class NewClass extends cc.Component {
15 |
16 | @property({type: cc.AudioClip})
17 | high_score_Audio: cc.AudioClip = null;
18 |
19 | // LIFE-CYCLE CALLBACKS:
20 |
21 | // use this for initialization
22 |
23 | onLoad() {
24 |
25 | }
26 |
27 | onCollisionEnter(other, self) {
28 | this.scheduleOnce(function () {
29 | cc.audioEngine.play(this.high_score_Audio, false, 1);
30 | }, 2);
31 | //cc.director.loadScene('LevelMenu');
32 | //Global.level2Open = true;
33 |
34 | this.scheduleOnce(function () {
35 | // 这里的 this 指向 component
36 | // cc.find('over').active = true;
37 | cc.game.restart();
38 | }, 2);
39 | }
40 |
41 | start() {
42 |
43 | }
44 |
45 | // update (dt) {}
46 | }
47 |
--------------------------------------------------------------------------------
/assets/object/castle/castle_script.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "20ac21a3-4035-4fb8-b0d2-dbef35bb1377",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/object/castle/castle_skin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/assets/object/castle/castle_skin.png
--------------------------------------------------------------------------------
/assets/object/castle/castle_skin.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.2.0",
3 | "uuid": "c3df0109-8ee0-48c4-a1a4-a945fb1757a3",
4 | "type": "sprite",
5 | "wrapMode": "clamp",
6 | "filterMode": "bilinear",
7 | "premultiplyAlpha": false,
8 | "subMetas": {
9 | "castle_skin": {
10 | "ver": "1.0.4",
11 | "uuid": "4165521b-f075-4980-845a-0a758ce2f4a6",
12 | "rawTextureUuid": "c3df0109-8ee0-48c4-a1a4-a945fb1757a3",
13 | "trimType": "auto",
14 | "trimThreshold": 1,
15 | "rotated": false,
16 | "offsetX": -1,
17 | "offsetY": -1.5,
18 | "trimX": 7,
19 | "trimY": 3,
20 | "width": 314,
21 | "height": 413,
22 | "rawWidth": 330,
23 | "rawHeight": 416,
24 | "borderTop": 0,
25 | "borderBottom": 0,
26 | "borderLeft": 0,
27 | "borderRight": 0,
28 | "subMetas": {}
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/assets/object/coin.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "08df1585-7729-4315-9925-1273b78f8377",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/coin/coin.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/assets/object/coin/coin.mp3
--------------------------------------------------------------------------------
/assets/object/coin/coin.mp3.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.0.0",
3 | "uuid": "57634600-68ea-4c0c-9af6-9354747947f1",
4 | "downloadMode": 0,
5 | "subMetas": {}
6 | }
--------------------------------------------------------------------------------
/assets/object/coin/coin_anim.anim:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.AnimationClip",
3 | "_name": "coin",
4 | "_objFlags": 0,
5 | "_rawFiles": null,
6 | "_duration": 1,
7 | "sample": 4,
8 | "speed": 1,
9 | "wrapMode": 2,
10 | "curveData": {
11 | "comps": {
12 | "cc.Sprite": {
13 | "spriteFrame": [
14 | {
15 | "frame": 0,
16 | "value": {
17 | "__uuid__": "5c63fb02-127b-4502-b213-d9a51a3d20cd"
18 | }
19 | },
20 | {
21 | "frame": 0.25,
22 | "value": {
23 | "__uuid__": "9dc5946a-7097-4ca0-bfdf-1d711be2fbec"
24 | }
25 | },
26 | {
27 | "frame": 0.5,
28 | "value": {
29 | "__uuid__": "550f0a21-0ace-46d1-82e7-4c7f3923f54f"
30 | }
31 | },
32 | {
33 | "frame": 0.75,
34 | "value": {
35 | "__uuid__": "05b2375d-ae75-4da6-add4-99623432d705"
36 | }
37 | }
38 | ]
39 | }
40 | }
41 | },
42 | "events": []
43 | }
--------------------------------------------------------------------------------
/assets/object/coin/coin_anim.anim.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.0",
3 | "uuid": "bbf11d08-0cdd-4128-8701-a14474d73fa6",
4 | "subMetas": {}
5 | }
--------------------------------------------------------------------------------
/assets/object/coin/coin_jump_node.prefab:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.Prefab",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "data": {
8 | "__id__": 1
9 | },
10 | "optimizationPolicy": 0,
11 | "asyncLoadAssets": false
12 | },
13 | {
14 | "__type__": "cc.Node",
15 | "_name": "CoinJump",
16 | "_objFlags": 0,
17 | "_parent": null,
18 | "_children": [],
19 | "_active": true,
20 | "_level": 1,
21 | "_components": [
22 | {
23 | "__id__": 2
24 | },
25 | {
26 | "__id__": 3
27 | },
28 | {
29 | "__id__": 4
30 | },
31 | {
32 | "__id__": 5
33 | }
34 | ],
35 | "_prefab": {
36 | "__id__": 6
37 | },
38 | "_opacity": 255,
39 | "_color": {
40 | "__type__": "cc.Color",
41 | "r": 255,
42 | "g": 255,
43 | "b": 255,
44 | "a": 255
45 | },
46 | "_contentSize": {
47 | "__type__": "cc.Size",
48 | "width": 47,
49 | "height": 46
50 | },
51 | "_anchorPoint": {
52 | "__type__": "cc.Vec2",
53 | "x": 0.5,
54 | "y": 0.5
55 | },
56 | "_position": {
57 | "__type__": "cc.Vec3",
58 | "x": 438,
59 | "y": 388,
60 | "z": 0
61 | },
62 | "_scale": {
63 | "__type__": "cc.Vec3",
64 | "x": 1,
65 | "y": 1,
66 | "z": 1
67 | },
68 | "_rotationX": 0,
69 | "_rotationY": 0,
70 | "_quat": {
71 | "__type__": "cc.Quat",
72 | "x": 0,
73 | "y": 0,
74 | "z": 0,
75 | "w": 1
76 | },
77 | "_skewX": 0,
78 | "_skewY": 0,
79 | "groupIndex": 4,
80 | "_id": ""
81 | },
82 | {
83 | "__type__": "cc.Sprite",
84 | "_name": "",
85 | "_objFlags": 0,
86 | "node": {
87 | "__id__": 1
88 | },
89 | "_enabled": true,
90 | "_srcBlendFactor": 770,
91 | "_dstBlendFactor": 771,
92 | "_spriteFrame": {
93 | "__uuid__": "5c63fb02-127b-4502-b213-d9a51a3d20cd"
94 | },
95 | "_type": 0,
96 | "_sizeMode": 1,
97 | "_fillType": 0,
98 | "_fillCenter": {
99 | "__type__": "cc.Vec2",
100 | "x": 0,
101 | "y": 0
102 | },
103 | "_fillStart": 0,
104 | "_fillRange": 0,
105 | "_isTrimmedMode": true,
106 | "_state": 0,
107 | "_atlas": {
108 | "__uuid__": "11eece11-856f-4b5f-b903-6573fdaa7f91"
109 | },
110 | "_id": ""
111 | },
112 | {
113 | "__type__": "cc.Animation",
114 | "_name": "",
115 | "_objFlags": 0,
116 | "node": {
117 | "__id__": 1
118 | },
119 | "_enabled": true,
120 | "_defaultClip": {
121 | "__uuid__": "bbf11d08-0cdd-4128-8701-a14474d73fa6"
122 | },
123 | "_clips": [
124 | {
125 | "__uuid__": "bbf11d08-0cdd-4128-8701-a14474d73fa6"
126 | }
127 | ],
128 | "playOnLoad": true,
129 | "_id": ""
130 | },
131 | {
132 | "__type__": "cc.CircleCollider",
133 | "_name": "",
134 | "_objFlags": 0,
135 | "node": {
136 | "__id__": 1
137 | },
138 | "_enabled": true,
139 | "tag": 1,
140 | "_offset": {
141 | "__type__": "cc.Vec2",
142 | "x": 0,
143 | "y": 0
144 | },
145 | "_radius": 25,
146 | "_id": ""
147 | },
148 | {
149 | "__type__": "2b82ev9qW1F3IDFyemlw2X3",
150 | "_name": "",
151 | "_objFlags": 0,
152 | "node": {
153 | "__id__": 1
154 | },
155 | "_enabled": true,
156 | "jumpHeight": 150,
157 | "jumpDuring": 0.5,
158 | "jumpAudio": {
159 | "__uuid__": "57634600-68ea-4c0c-9af6-9354747947f1"
160 | },
161 | "_id": ""
162 | },
163 | {
164 | "__type__": "cc.PrefabInfo",
165 | "root": {
166 | "__id__": 1
167 | },
168 | "asset": {
169 | "__uuid__": "f0a27f46-5b77-4fce-8986-70a1268c268e"
170 | },
171 | "fileId": "75qTfnAkRJ3aqEJIIMV+QR",
172 | "sync": false
173 | }
174 | ]
--------------------------------------------------------------------------------
/assets/object/coin/coin_jump_node.prefab.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "f0a27f46-5b77-4fce-8986-70a1268c268e",
4 | "optimizationPolicy": "AUTO",
5 | "asyncLoadAssets": false,
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/coin/coin_node.prefab:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.Prefab",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "data": {
8 | "__id__": 1
9 | },
10 | "optimizationPolicy": 0,
11 | "asyncLoadAssets": false
12 | },
13 | {
14 | "__type__": "cc.Node",
15 | "_name": "coin",
16 | "_objFlags": 0,
17 | "_parent": null,
18 | "_children": [],
19 | "_active": true,
20 | "_level": 1,
21 | "_components": [
22 | {
23 | "__id__": 2
24 | },
25 | {
26 | "__id__": 3
27 | },
28 | {
29 | "__id__": 4
30 | }
31 | ],
32 | "_prefab": {
33 | "__id__": 5
34 | },
35 | "_opacity": 255,
36 | "_color": {
37 | "__type__": "cc.Color",
38 | "r": 255,
39 | "g": 255,
40 | "b": 255,
41 | "a": 255
42 | },
43 | "_contentSize": {
44 | "__type__": "cc.Size",
45 | "width": 47,
46 | "height": 46
47 | },
48 | "_anchorPoint": {
49 | "__type__": "cc.Vec2",
50 | "x": 0.5,
51 | "y": 0.5
52 | },
53 | "_position": {
54 | "__type__": "cc.Vec3",
55 | "x": -13,
56 | "y": 0,
57 | "z": 0
58 | },
59 | "_scale": {
60 | "__type__": "cc.Vec3",
61 | "x": 1,
62 | "y": 1,
63 | "z": 1
64 | },
65 | "_rotationX": 0,
66 | "_rotationY": 0,
67 | "_quat": {
68 | "__type__": "cc.Quat",
69 | "x": 0,
70 | "y": 0,
71 | "z": 0,
72 | "w": 1
73 | },
74 | "_skewX": 0,
75 | "_skewY": 0,
76 | "groupIndex": 4,
77 | "_id": ""
78 | },
79 | {
80 | "__type__": "cc.Sprite",
81 | "_name": "",
82 | "_objFlags": 0,
83 | "node": {
84 | "__id__": 1
85 | },
86 | "_enabled": true,
87 | "_srcBlendFactor": 770,
88 | "_dstBlendFactor": 771,
89 | "_spriteFrame": {
90 | "__uuid__": "5c63fb02-127b-4502-b213-d9a51a3d20cd"
91 | },
92 | "_type": 0,
93 | "_sizeMode": 1,
94 | "_fillType": 0,
95 | "_fillCenter": {
96 | "__type__": "cc.Vec2",
97 | "x": 0,
98 | "y": 0
99 | },
100 | "_fillStart": 0,
101 | "_fillRange": 0,
102 | "_isTrimmedMode": true,
103 | "_state": 0,
104 | "_atlas": {
105 | "__uuid__": "11eece11-856f-4b5f-b903-6573fdaa7f91"
106 | },
107 | "_id": ""
108 | },
109 | {
110 | "__type__": "cc.Animation",
111 | "_name": "",
112 | "_objFlags": 0,
113 | "node": {
114 | "__id__": 1
115 | },
116 | "_enabled": true,
117 | "_defaultClip": {
118 | "__uuid__": "bbf11d08-0cdd-4128-8701-a14474d73fa6"
119 | },
120 | "_clips": [
121 | {
122 | "__uuid__": "bbf11d08-0cdd-4128-8701-a14474d73fa6"
123 | }
124 | ],
125 | "playOnLoad": true,
126 | "_id": ""
127 | },
128 | {
129 | "__type__": "cc.CircleCollider",
130 | "_name": "",
131 | "_objFlags": 0,
132 | "node": {
133 | "__id__": 1
134 | },
135 | "_enabled": true,
136 | "tag": 1,
137 | "_offset": {
138 | "__type__": "cc.Vec2",
139 | "x": 0,
140 | "y": 0
141 | },
142 | "_radius": 25,
143 | "_id": ""
144 | },
145 | {
146 | "__type__": "cc.PrefabInfo",
147 | "root": {
148 | "__id__": 1
149 | },
150 | "asset": {
151 | "__uuid__": "21843bb5-5769-4f83-aaf8-00c90177fb84"
152 | },
153 | "fileId": "4eYU6UMs9Mj4TkuJeV135P",
154 | "sync": false
155 | }
156 | ]
--------------------------------------------------------------------------------
/assets/object/coin/coin_node.prefab.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "21843bb5-5769-4f83-aaf8-00c90177fb84",
4 | "optimizationPolicy": "AUTO",
5 | "asyncLoadAssets": false,
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/coin/coin_script.ts:
--------------------------------------------------------------------------------
1 | // Learn TypeScript:
2 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
3 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
4 | // Learn Attribute:
5 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
6 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
7 | // Learn life-cycle callbacks:
8 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
9 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
10 |
11 | const { ccclass, property } = cc._decorator;
12 |
13 | @ccclass
14 | export default class NewClass extends cc.Component {
15 |
16 | @property
17 | jumpHeight: number = 0;
18 |
19 | @property
20 | jumpDuring: number = 0;
21 |
22 | @property({type:cc.AudioClip})
23 | jumpAudio: cc.AudioClip = null;
24 |
25 | jumpAction: cc.Action = null;
26 |
27 | // LIFE-CYCLE CALLBACKS:
28 |
29 | onLoad() {
30 | this.jumpAction = this.setJumpAction();
31 |
32 | this.node.runAction(this.jumpAction);
33 | // this.node.removeFromParent();
34 | this.scheduleOnce(function () {
35 | // 这里的 this 指向 component
36 | this.node.removeFromParent();
37 | }, 1);
38 | // var seq = cc.sequence(cc.moveBy(1, 0, 200), cc.moveBy(1, 0,-200));
39 | // this.node.runAction(seq);
40 | }
41 |
42 | start() {
43 |
44 | }
45 |
46 | setJumpAction() {
47 | var fadeIn = cc.fadeIn(0);
48 | var fadeOut = cc.fadeOut(1);
49 | var jumpUp = cc.moveBy(this.jumpDuring, new cc.Vec2(0, this.jumpHeight)).easing(cc.easeCubicActionOut());// 先快后慢
50 | var jumpDown = cc.moveBy(this.jumpDuring, new cc.Vec2(0, -this.jumpHeight)).easing(cc.easeCubicActionIn());//缓动 先慢后快
51 | // var callback = cc.callFunc(this.playJumpSound,this);
52 | // return cc.sequence(callback,fadeIn,jumpUp, jumpDown,fadeOut);
53 | return cc.sequence(fadeIn, jumpUp, jumpDown, fadeOut);
54 | }
55 |
56 | // update (dt) {}
57 | }
58 |
--------------------------------------------------------------------------------
/assets/object/coin/coin_script.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "2b82ebfd-a96d-45dc-80c5-c9e9a5c365f7",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/object/coin/coin_skin.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | frames
6 |
7 | coin_01.png
8 |
9 | aliases
10 |
11 | spriteOffset
12 | {0,0}
13 | spriteSize
14 | {47,46}
15 | spriteSourceSize
16 | {47,46}
17 | textureRect
18 | {{1,95},{47,46}}
19 | textureRotated
20 |
21 |
22 | coin_02.png
23 |
24 | aliases
25 |
26 | spriteOffset
27 | {0,0}
28 | spriteSize
29 | {39,46}
30 | spriteSourceSize
31 | {39,46}
32 | textureRect
33 | {{1,54},{39,46}}
34 | textureRotated
35 |
36 |
37 | coin_03.png
38 |
39 | aliases
40 |
41 | spriteOffset
42 | {0,0}
43 | spriteSize
44 | {11,46}
45 | spriteSourceSize
46 | {11,46}
47 | textureRect
48 | {{1,1},{11,46}}
49 | textureRotated
50 |
51 |
52 | coin_04.png
53 |
54 | aliases
55 |
56 | spriteOffset
57 | {0,0}
58 | spriteSize
59 | {38,46}
60 | spriteSourceSize
61 | {38,46}
62 | textureRect
63 | {{1,14},{38,46}}
64 | textureRotated
65 |
66 |
67 |
68 | metadata
69 |
70 | format
71 | 3
72 | pixelFormat
73 | RGBA8888
74 | premultiplyAlpha
75 |
76 | realTextureFileName
77 | coin_skin.png
78 | size
79 | {49,142}
80 | smartupdate
81 | $TexturePacker:SmartUpdate:7599731bce13a3207cdf14d6111507b0:62065a8d6149aaeadaaa71fa74948a1e:6059f2e151ca252af15be5b1fdbd8cf4$
82 | textureFileName
83 | coin_skin.png
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/assets/object/coin/coin_skin.plist.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.2.4",
3 | "uuid": "11eece11-856f-4b5f-b903-6573fdaa7f91",
4 | "rawTextureUuid": "c3b55e0c-7c5c-478a-b89b-f639e3d76374",
5 | "size": {
6 | "width": 49,
7 | "height": 142
8 | },
9 | "type": "Texture Packer",
10 | "subMetas": {
11 | "coin_01.png": {
12 | "ver": "1.0.4",
13 | "uuid": "5c63fb02-127b-4502-b213-d9a51a3d20cd",
14 | "rawTextureUuid": "c3b55e0c-7c5c-478a-b89b-f639e3d76374",
15 | "trimType": "auto",
16 | "trimThreshold": 1,
17 | "rotated": false,
18 | "offsetX": 0,
19 | "offsetY": 0,
20 | "trimX": 1,
21 | "trimY": 95,
22 | "width": 47,
23 | "height": 46,
24 | "rawWidth": 47,
25 | "rawHeight": 46,
26 | "borderTop": 0,
27 | "borderBottom": 0,
28 | "borderLeft": 0,
29 | "borderRight": 0,
30 | "spriteType": "normal",
31 | "subMetas": {}
32 | },
33 | "coin_02.png": {
34 | "ver": "1.0.4",
35 | "uuid": "9dc5946a-7097-4ca0-bfdf-1d711be2fbec",
36 | "rawTextureUuid": "c3b55e0c-7c5c-478a-b89b-f639e3d76374",
37 | "trimType": "auto",
38 | "trimThreshold": 1,
39 | "rotated": true,
40 | "offsetX": 0,
41 | "offsetY": 0,
42 | "trimX": 1,
43 | "trimY": 54,
44 | "width": 39,
45 | "height": 46,
46 | "rawWidth": 39,
47 | "rawHeight": 46,
48 | "borderTop": 0,
49 | "borderBottom": 0,
50 | "borderLeft": 0,
51 | "borderRight": 0,
52 | "spriteType": "normal",
53 | "subMetas": {}
54 | },
55 | "coin_03.png": {
56 | "ver": "1.0.4",
57 | "uuid": "550f0a21-0ace-46d1-82e7-4c7f3923f54f",
58 | "rawTextureUuid": "c3b55e0c-7c5c-478a-b89b-f639e3d76374",
59 | "trimType": "auto",
60 | "trimThreshold": 1,
61 | "rotated": true,
62 | "offsetX": 0,
63 | "offsetY": 0,
64 | "trimX": 1,
65 | "trimY": 1,
66 | "width": 11,
67 | "height": 46,
68 | "rawWidth": 11,
69 | "rawHeight": 46,
70 | "borderTop": 0,
71 | "borderBottom": 0,
72 | "borderLeft": 0,
73 | "borderRight": 0,
74 | "spriteType": "normal",
75 | "subMetas": {}
76 | },
77 | "coin_04.png": {
78 | "ver": "1.0.4",
79 | "uuid": "05b2375d-ae75-4da6-add4-99623432d705",
80 | "rawTextureUuid": "c3b55e0c-7c5c-478a-b89b-f639e3d76374",
81 | "trimType": "auto",
82 | "trimThreshold": 1,
83 | "rotated": true,
84 | "offsetX": 0,
85 | "offsetY": 0,
86 | "trimX": 1,
87 | "trimY": 14,
88 | "width": 38,
89 | "height": 46,
90 | "rawWidth": 38,
91 | "rawHeight": 46,
92 | "borderTop": 0,
93 | "borderBottom": 0,
94 | "borderLeft": 0,
95 | "borderRight": 0,
96 | "spriteType": "normal",
97 | "subMetas": {}
98 | }
99 | }
100 | }
--------------------------------------------------------------------------------
/assets/object/coin/coin_skin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/assets/object/coin/coin_skin.png
--------------------------------------------------------------------------------
/assets/object/coin/coin_skin.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.2.0",
3 | "uuid": "c3b55e0c-7c5c-478a-b89b-f639e3d76374",
4 | "type": "sprite",
5 | "wrapMode": "clamp",
6 | "filterMode": "bilinear",
7 | "premultiplyAlpha": false,
8 | "subMetas": {
9 | "coin_skin": {
10 | "ver": "1.0.4",
11 | "uuid": "17c2c342-91f5-46f5-8e36-fb3b67cfd4fa",
12 | "rawTextureUuid": "c3b55e0c-7c5c-478a-b89b-f639e3d76374",
13 | "trimType": "auto",
14 | "trimThreshold": 1,
15 | "rotated": false,
16 | "offsetX": 0,
17 | "offsetY": 0,
18 | "trimX": 0,
19 | "trimY": 0,
20 | "width": 49,
21 | "height": 142,
22 | "rawWidth": 49,
23 | "rawHeight": 142,
24 | "borderTop": 0,
25 | "borderBottom": 0,
26 | "borderLeft": 0,
27 | "borderRight": 0,
28 | "subMetas": {}
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/assets/object/mushroom.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "a3a17f34-8fa1-4d04-a86a-dca4b5016763",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/mushroom/mushroom_appear.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/assets/object/mushroom/mushroom_appear.mp3
--------------------------------------------------------------------------------
/assets/object/mushroom/mushroom_appear.mp3.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.0.0",
3 | "uuid": "75628113-2d8e-412d-a887-be8239a04422",
4 | "downloadMode": 0,
5 | "subMetas": {}
6 | }
--------------------------------------------------------------------------------
/assets/object/mushroom/mushroom_catch.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/assets/object/mushroom/mushroom_catch.mp3
--------------------------------------------------------------------------------
/assets/object/mushroom/mushroom_catch.mp3.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.0.0",
3 | "uuid": "536e4e1b-9de9-4eab-9b5f-e7989998d361",
4 | "downloadMode": 0,
5 | "subMetas": {}
6 | }
--------------------------------------------------------------------------------
/assets/object/mushroom/mushroom_node.prefab:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.Prefab",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "data": {
8 | "__id__": 1
9 | },
10 | "optimizationPolicy": 0,
11 | "asyncLoadAssets": false
12 | },
13 | {
14 | "__type__": "cc.Node",
15 | "_name": "mushroom_node",
16 | "_objFlags": 0,
17 | "_parent": null,
18 | "_children": [],
19 | "_active": true,
20 | "_level": 1,
21 | "_components": [
22 | {
23 | "__id__": 2
24 | },
25 | {
26 | "__id__": 3
27 | },
28 | {
29 | "__id__": 4
30 | }
31 | ],
32 | "_prefab": {
33 | "__id__": 5
34 | },
35 | "_opacity": 255,
36 | "_color": {
37 | "__type__": "cc.Color",
38 | "r": 255,
39 | "g": 255,
40 | "b": 255,
41 | "a": 255
42 | },
43 | "_contentSize": {
44 | "__type__": "cc.Size",
45 | "width": 58,
46 | "height": 60
47 | },
48 | "_anchorPoint": {
49 | "__type__": "cc.Vec2",
50 | "x": 0.5,
51 | "y": 0.5
52 | },
53 | "_position": {
54 | "__type__": "cc.Vec3",
55 | "x": 706,
56 | "y": 557,
57 | "z": 0
58 | },
59 | "_scale": {
60 | "__type__": "cc.Vec3",
61 | "x": 1,
62 | "y": 1,
63 | "z": 1
64 | },
65 | "_rotationX": 0,
66 | "_rotationY": 0,
67 | "_quat": {
68 | "__type__": "cc.Quat",
69 | "x": 0,
70 | "y": 0,
71 | "z": 0,
72 | "w": 1
73 | },
74 | "_skewX": 0,
75 | "_skewY": 0,
76 | "groupIndex": 7,
77 | "_id": ""
78 | },
79 | {
80 | "__type__": "cc.Sprite",
81 | "_name": "",
82 | "_objFlags": 0,
83 | "node": {
84 | "__id__": 1
85 | },
86 | "_enabled": true,
87 | "_srcBlendFactor": 770,
88 | "_dstBlendFactor": 771,
89 | "_spriteFrame": {
90 | "__uuid__": "a760b6f7-871f-4024-b9f9-5423d4c431b9"
91 | },
92 | "_type": 0,
93 | "_sizeMode": 1,
94 | "_fillType": 0,
95 | "_fillCenter": {
96 | "__type__": "cc.Vec2",
97 | "x": 0,
98 | "y": 0
99 | },
100 | "_fillStart": 0,
101 | "_fillRange": 0,
102 | "_isTrimmedMode": true,
103 | "_state": 0,
104 | "_atlas": {
105 | "__uuid__": "38407f42-2322-4113-8ca0-2544ced66cc0"
106 | },
107 | "_id": ""
108 | },
109 | {
110 | "__type__": "cc.BoxCollider",
111 | "_name": "",
112 | "_objFlags": 0,
113 | "node": {
114 | "__id__": 1
115 | },
116 | "_enabled": true,
117 | "tag": 8,
118 | "_offset": {
119 | "__type__": "cc.Vec2",
120 | "x": 0,
121 | "y": 0
122 | },
123 | "_size": {
124 | "__type__": "cc.Size",
125 | "width": 58,
126 | "height": 60
127 | },
128 | "_id": ""
129 | },
130 | {
131 | "__type__": "00158jgj9pGHKddLRSg92sk",
132 | "_name": "",
133 | "_objFlags": 0,
134 | "node": {
135 | "__id__": 1
136 | },
137 | "_enabled": true,
138 | "gravity": -1000,
139 | "jumpHeight": 70,
140 | "jumpDuring": 0.5,
141 | "speed": {
142 | "__type__": "cc.Vec2",
143 | "x": 0,
144 | "y": 0
145 | },
146 | "maxSpeed": {
147 | "__type__": "cc.Vec2",
148 | "x": 200,
149 | "y": 2000
150 | },
151 | "mushroom_catch_Audio": {
152 | "__uuid__": "536e4e1b-9de9-4eab-9b5f-e7989998d361"
153 | },
154 | "mushroom_appear_Audio": {
155 | "__uuid__": "75628113-2d8e-412d-a887-be8239a04422"
156 | },
157 | "_id": ""
158 | },
159 | {
160 | "__type__": "cc.PrefabInfo",
161 | "root": {
162 | "__id__": 1
163 | },
164 | "asset": {
165 | "__uuid__": "d67a786a-3613-470f-824e-6aa547e0af00"
166 | },
167 | "fileId": "beRTXt9JBDD5M86RPOzj9d",
168 | "sync": false
169 | }
170 | ]
--------------------------------------------------------------------------------
/assets/object/mushroom/mushroom_node.prefab.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "d67a786a-3613-470f-824e-6aa547e0af00",
4 | "optimizationPolicy": "AUTO",
5 | "asyncLoadAssets": false,
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/mushroom/mushroom_script.ts:
--------------------------------------------------------------------------------
1 | // Learn TypeScript:
2 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
3 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
4 | // Learn Attribute:
5 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
6 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
7 | // Learn life-cycle callbacks:
8 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
9 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
10 |
11 | const { ccclass, property } = cc._decorator;
12 |
13 | @ccclass
14 | export default class NewClass extends cc.Component {
15 |
16 | @property()
17 | gravity: number = -1000;
18 |
19 | @property()
20 | jumpHeight: number = 0;//跳高
21 |
22 | @property()
23 | jumpDuring: number = 0;//持续时间
24 |
25 | @property()
26 | speed: cc.Vec2 = new cc.Vec2(0, 0);
27 |
28 | @property()
29 | maxSpeed: cc.Vec2 = new cc.Vec2(2000, 2000);
30 |
31 | @property({type: cc.AudioClip})
32 | mushroom_catch_Audio: cc.AudioClip = null;
33 |
34 | @property({type: cc.AudioClip})
35 | mushroom_appear_Audio: cc.AudioClip = null;
36 |
37 | touchingNumber: number = 0;
38 | jumpAction: cc.Action = null;
39 |
40 | // LIFE-CYCLE CALLBACKS:
41 |
42 | onLoad() {
43 | this.touchingNumber = 0;
44 | cc.audioEngine.play(this.mushroom_appear_Audio, false, 1);
45 | this.jumpAction = this.setJumpAction();
46 | this.node.runAction(this.jumpAction);
47 | }
48 |
49 | start() {
50 |
51 | }
52 |
53 | setJumpAction() {
54 | var fadeIn = cc.fadeIn(0);
55 | // var fadeOut = cc.fadeOut(1);
56 | var jumpUp = cc.moveBy(this.jumpDuring, new cc.Vec2(0, this.jumpHeight)).easing(cc.easeCubicActionOut());// 先快后慢
57 | // var moveRight = cc.moveBy( cc.p(10, 0));
58 | // var callback = cc.callFunc(this.playJumpSound,this);
59 | // return cc.sequence(callback,fadeIn,jumpUp, jumpDown,fadeOut);
60 |
61 | return cc.sequence(fadeIn, jumpUp);
62 | }
63 |
64 | onCollisionEnter(other, self) {
65 |
66 | var otherAabb = other.world.aabb;
67 | var otherPreAabb = other.world.preAabb.clone();
68 |
69 | var selfAabb = self.world.aabb;
70 | var selfPreAabb = self.world.preAabb.clone();
71 | selfPreAabb.y = selfAabb.y;
72 | otherPreAabb.y = otherAabb.y;
73 | if (other.tag == 2 || other.tag == 3 || other.tag == 5) {
74 | this.touchingNumber++;
75 | }
76 | if (other.tag == 0) {
77 | //cc.audioEngine.play(this.mushroom_catch_Audio, false, Global.volume);
78 | //Global.addSpeed = 1.2;//玩家1.2倍速度
79 | this.scheduleOnce(function () {
80 | // console.log('mushroom onCollisionEnter');
81 | this.node.removeFromParent();
82 | }, 0.2);
83 | }
84 | if (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
85 |
86 | }
87 | }
88 | onCollisionExit(other) {
89 |
90 | if (other.tag == 2 || other.tag == 3 || other.tag == 5) {
91 | this.touchingNumber--;
92 | }
93 |
94 | }
95 |
96 | // called every frame, uncomment this function to activate update callback
97 | update(dt) {
98 | // console.log("this.touchingNumber: " + this.touchingNumber);
99 | // if (this.collisionY === 0)
100 | if (this.touchingNumber === 0) {
101 | this.speed.y += this.gravity * dt;
102 | if (Math.abs(this.speed.y) > this.maxSpeed.y) {
103 | this.speed.y = this.speed.y > 0 ? this.maxSpeed.y : -this.maxSpeed.y;
104 | }
105 | }
106 | // this.node.x++;
107 | // this.node.y += this.speed.y * dt;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/assets/object/mushroom/mushroom_script.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "001588e0-8fda-461c-a75d-2d14a0f76b24",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/object/mushroom/mushroom_skin.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | frames
6 |
7 | mushroom.png
8 |
9 | aliases
10 |
11 | spriteOffset
12 | {0,4}
13 | spriteSize
14 | {58,60}
15 | spriteSourceSize
16 | {64,74}
17 | textureRect
18 | {{1,1},{58,60}}
19 | textureRotated
20 |
21 |
22 | mushroom2.png
23 |
24 | aliases
25 |
26 | spriteOffset
27 | {0,4}
28 | spriteSize
29 | {58,60}
30 | spriteSourceSize
31 | {64,74}
32 | textureRect
33 | {{61,1},{58,60}}
34 | textureRotated
35 |
36 |
37 | mushroom22.png
38 |
39 | aliases
40 |
41 | spriteOffset
42 | {0,4}
43 | spriteSize
44 | {58,60}
45 | spriteSourceSize
46 | {64,74}
47 | textureRect
48 | {{121,1},{58,60}}
49 | textureRotated
50 |
51 |
52 |
53 | metadata
54 |
55 | format
56 | 3
57 | pixelFormat
58 | RGBA8888
59 | premultiplyAlpha
60 |
61 | realTextureFileName
62 | mushroom_skin.png
63 | size
64 | {180,62}
65 | smartupdate
66 | $TexturePacker:SmartUpdate:7d00876db52bc6562e0cb3573b37e879:aed6a7b0879ebf33daf0444e3d84a410:d9661e4c8a014435d5839e48826354c5$
67 | textureFileName
68 | mushroom_skin.png
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/assets/object/mushroom/mushroom_skin.plist.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.2.4",
3 | "uuid": "38407f42-2322-4113-8ca0-2544ced66cc0",
4 | "rawTextureUuid": "7ef95f49-afca-420a-98d4-0f431e1c8fb7",
5 | "size": {
6 | "width": 180,
7 | "height": 62
8 | },
9 | "type": "Texture Packer",
10 | "subMetas": {
11 | "mushroom.png": {
12 | "ver": "1.0.4",
13 | "uuid": "a760b6f7-871f-4024-b9f9-5423d4c431b9",
14 | "rawTextureUuid": "7ef95f49-afca-420a-98d4-0f431e1c8fb7",
15 | "trimType": "auto",
16 | "trimThreshold": 1,
17 | "rotated": false,
18 | "offsetX": 0,
19 | "offsetY": 4,
20 | "trimX": 1,
21 | "trimY": 1,
22 | "width": 58,
23 | "height": 60,
24 | "rawWidth": 64,
25 | "rawHeight": 74,
26 | "borderTop": 0,
27 | "borderBottom": 0,
28 | "borderLeft": 0,
29 | "borderRight": 0,
30 | "spriteType": "normal",
31 | "subMetas": {}
32 | },
33 | "mushroom2.png": {
34 | "ver": "1.0.4",
35 | "uuid": "a49c0ac5-d997-4e37-ad5f-ccb4f8b83dc7",
36 | "rawTextureUuid": "7ef95f49-afca-420a-98d4-0f431e1c8fb7",
37 | "trimType": "auto",
38 | "trimThreshold": 1,
39 | "rotated": false,
40 | "offsetX": 0,
41 | "offsetY": 4,
42 | "trimX": 61,
43 | "trimY": 1,
44 | "width": 58,
45 | "height": 60,
46 | "rawWidth": 64,
47 | "rawHeight": 74,
48 | "borderTop": 0,
49 | "borderBottom": 0,
50 | "borderLeft": 0,
51 | "borderRight": 0,
52 | "spriteType": "normal",
53 | "subMetas": {}
54 | },
55 | "mushroom22.png": {
56 | "ver": "1.0.4",
57 | "uuid": "3e922bee-2c81-402c-b3e0-ad8d33e96354",
58 | "rawTextureUuid": "7ef95f49-afca-420a-98d4-0f431e1c8fb7",
59 | "trimType": "auto",
60 | "trimThreshold": 1,
61 | "rotated": false,
62 | "offsetX": 0,
63 | "offsetY": 4,
64 | "trimX": 121,
65 | "trimY": 1,
66 | "width": 58,
67 | "height": 60,
68 | "rawWidth": 64,
69 | "rawHeight": 74,
70 | "borderTop": 0,
71 | "borderBottom": 0,
72 | "borderLeft": 0,
73 | "borderRight": 0,
74 | "spriteType": "normal",
75 | "subMetas": {}
76 | }
77 | }
78 | }
--------------------------------------------------------------------------------
/assets/object/mushroom/mushroom_skin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/assets/object/mushroom/mushroom_skin.png
--------------------------------------------------------------------------------
/assets/object/mushroom/mushroom_skin.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.2.0",
3 | "uuid": "7ef95f49-afca-420a-98d4-0f431e1c8fb7",
4 | "type": "sprite",
5 | "wrapMode": "clamp",
6 | "filterMode": "bilinear",
7 | "premultiplyAlpha": false,
8 | "subMetas": {
9 | "mushroom_skin": {
10 | "ver": "1.0.4",
11 | "uuid": "586c7d41-f0f3-43fd-ab85-e08fc402d977",
12 | "rawTextureUuid": "7ef95f49-afca-420a-98d4-0f431e1c8fb7",
13 | "trimType": "auto",
14 | "trimThreshold": 1,
15 | "rotated": false,
16 | "offsetX": 0.5,
17 | "offsetY": 0,
18 | "trimX": 3,
19 | "trimY": 2,
20 | "width": 175,
21 | "height": 58,
22 | "rawWidth": 180,
23 | "rawHeight": 62,
24 | "borderTop": 0,
25 | "borderBottom": 0,
26 | "borderLeft": 0,
27 | "borderRight": 0,
28 | "subMetas": {}
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/assets/object/player.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "6b2e811a-b200-45db-9bcd-7d6f55d26c8c",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/player/player.prefab:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.Prefab",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "data": {
8 | "__id__": 1
9 | },
10 | "optimizationPolicy": 0,
11 | "asyncLoadAssets": false
12 | },
13 | {
14 | "__type__": "cc.Node",
15 | "_name": "player",
16 | "_objFlags": 512,
17 | "_parent": null,
18 | "_children": [],
19 | "_active": true,
20 | "_level": 1,
21 | "_components": [
22 | {
23 | "__id__": 2
24 | },
25 | {
26 | "__id__": 3
27 | },
28 | {
29 | "__id__": 4
30 | },
31 | {
32 | "__id__": 5
33 | }
34 | ],
35 | "_prefab": {
36 | "__id__": 6
37 | },
38 | "_opacity": 255,
39 | "_color": {
40 | "__type__": "cc.Color",
41 | "r": 255,
42 | "g": 255,
43 | "b": 255,
44 | "a": 255
45 | },
46 | "_contentSize": {
47 | "__type__": "cc.Size",
48 | "width": 49.2,
49 | "height": 60
50 | },
51 | "_anchorPoint": {
52 | "__type__": "cc.Vec2",
53 | "x": 0.5,
54 | "y": 0
55 | },
56 | "_position": {
57 | "__type__": "cc.Vec3",
58 | "x": 87,
59 | "y": 197,
60 | "z": 0
61 | },
62 | "_scale": {
63 | "__type__": "cc.Vec3",
64 | "x": 1,
65 | "y": 1,
66 | "z": 1
67 | },
68 | "_rotationX": 0,
69 | "_rotationY": 0,
70 | "_quat": {
71 | "__type__": "cc.Quat",
72 | "x": 0,
73 | "y": 0,
74 | "z": 0,
75 | "w": 1
76 | },
77 | "_skewX": 0,
78 | "_skewY": 0,
79 | "groupIndex": 1,
80 | "_id": ""
81 | },
82 | {
83 | "__type__": "cc.Sprite",
84 | "_name": "",
85 | "_objFlags": 0,
86 | "node": {
87 | "__id__": 1
88 | },
89 | "_enabled": true,
90 | "_srcBlendFactor": 770,
91 | "_dstBlendFactor": 771,
92 | "_spriteFrame": {
93 | "__uuid__": "b1334959-77a3-4574-95ef-50803db2f5e0"
94 | },
95 | "_type": 0,
96 | "_sizeMode": 0,
97 | "_fillType": 0,
98 | "_fillCenter": {
99 | "__type__": "cc.Vec2",
100 | "x": 0,
101 | "y": 0
102 | },
103 | "_fillStart": 0,
104 | "_fillRange": 0,
105 | "_isTrimmedMode": true,
106 | "_state": 0,
107 | "_atlas": {
108 | "__uuid__": "63eb1a99-3a34-4e40-bdc3-f09302d45cc6"
109 | },
110 | "_id": ""
111 | },
112 | {
113 | "__type__": "cc.Animation",
114 | "_name": "",
115 | "_objFlags": 0,
116 | "node": {
117 | "__id__": 1
118 | },
119 | "_enabled": true,
120 | "_defaultClip": {
121 | "__uuid__": "04c53391-7a36-4267-b7f0-596a644861b4"
122 | },
123 | "_clips": [
124 | {
125 | "__uuid__": "04c53391-7a36-4267-b7f0-596a644861b4"
126 | },
127 | {
128 | "__uuid__": "766c94a6-03ff-47a7-9470-62e124fe3fa1"
129 | },
130 | {
131 | "__uuid__": "f0ee03ce-7867-4838-a381-800f70efa578"
132 | },
133 | {
134 | "__uuid__": "deb66f55-f8ca-4db2-bc4e-ca33e6cb98ce"
135 | },
136 | {
137 | "__uuid__": "b240e23c-3dfb-4bff-8328-424f697d80e3"
138 | },
139 | {
140 | "__uuid__": "bf5e4641-c8f6-442c-aa1b-8ad807548c76"
141 | }
142 | ],
143 | "playOnLoad": true,
144 | "_id": ""
145 | },
146 | {
147 | "__type__": "326b8b6lOFHWLzFPac1lrNy",
148 | "_name": "",
149 | "_objFlags": 0,
150 | "node": {
151 | "__id__": 1
152 | },
153 | "_enabled": true,
154 | "anim": {
155 | "__id__": 3
156 | },
157 | "maxSpeedV2": {
158 | "__type__": "cc.Vec2",
159 | "x": 200,
160 | "y": 2000
161 | },
162 | "dieAudio": null,
163 | "jumpAudio": null,
164 | "player_decrease_Audio": null,
165 | "hit_block_Audio": null,
166 | "jumpSpeed": 700,
167 | "_id": ""
168 | },
169 | {
170 | "__type__": "cc.PolygonCollider",
171 | "_name": "",
172 | "_objFlags": 0,
173 | "node": {
174 | "__id__": 1
175 | },
176 | "_enabled": true,
177 | "tag": 0,
178 | "_offset": {
179 | "__type__": "cc.Vec2",
180 | "x": 0,
181 | "y": 0
182 | },
183 | "points": [
184 | {
185 | "__type__": "cc.Vec2",
186 | "x": -25,
187 | "y": 0
188 | },
189 | {
190 | "__type__": "cc.Vec2",
191 | "x": 25,
192 | "y": 0
193 | },
194 | {
195 | "__type__": "cc.Vec2",
196 | "x": 25,
197 | "y": 60
198 | },
199 | {
200 | "__type__": "cc.Vec2",
201 | "x": -25,
202 | "y": 60
203 | }
204 | ],
205 | "_id": ""
206 | },
207 | {
208 | "__type__": "cc.PrefabInfo",
209 | "root": {
210 | "__id__": 1
211 | },
212 | "asset": {
213 | "__uuid__": "33658c29-2167-43ae-be5c-77511d1cf205"
214 | },
215 | "fileId": "3cr+opwnpDkZc0wSqjTuWZ",
216 | "sync": false
217 | }
218 | ]
--------------------------------------------------------------------------------
/assets/object/player/player.prefab.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "33658c29-2167-43ae-be5c-77511d1cf205",
4 | "optimizationPolicy": "AUTO",
5 | "asyncLoadAssets": false,
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/player/skin.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "c1570db5-10b5-4da5-a6e0-ac1286e66eaa",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "2ab242b0-cc0a-4806-91f6-8fec86ce619e",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player.anim:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.AnimationClip",
3 | "_name": "",
4 | "_objFlags": 0,
5 | "_duration": 0,
6 | "sample": 60,
7 | "curveData": {},
8 | "events": []
9 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player.anim.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.0",
3 | "uuid": "9ca03d9a-1c3f-430d-bfa1-67aaff70094b",
4 | "subMetas": {}
5 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/assets/object/player/skin/rabbit/player.png
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.2.0",
3 | "uuid": "0b06ba15-ddc6-43b4-bb8e-f4bb485ccc51",
4 | "type": "sprite",
5 | "wrapMode": "clamp",
6 | "filterMode": "bilinear",
7 | "premultiplyAlpha": false,
8 | "subMetas": {
9 | "player": {
10 | "ver": "1.0.4",
11 | "uuid": "864934be-78cb-46c5-8f46-83cb4da93c2d",
12 | "rawTextureUuid": "0b06ba15-ddc6-43b4-bb8e-f4bb485ccc51",
13 | "trimType": "auto",
14 | "trimThreshold": 1,
15 | "rotated": false,
16 | "offsetX": 0,
17 | "offsetY": 0,
18 | "trimX": 0,
19 | "trimY": 0,
20 | "width": 507,
21 | "height": 878,
22 | "rawWidth": 507,
23 | "rawHeight": 878,
24 | "borderTop": 0,
25 | "borderBottom": 0,
26 | "borderLeft": 0,
27 | "borderRight": 0,
28 | "subMetas": {}
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player_die.anim:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.AnimationClip",
3 | "_name": "player_die",
4 | "_objFlags": 0,
5 | "_rawFiles": null,
6 | "_duration": 1,
7 | "sample": 1,
8 | "speed": 1,
9 | "wrapMode": 1,
10 | "curveData": {
11 | "comps": {
12 | "cc.Sprite": {
13 | "spriteFrame": [
14 | {
15 | "frame": 0,
16 | "value": {
17 | "__uuid__": "1d950e0e-c156-41ca-91d1-c5213105e643"
18 | }
19 | }
20 | ]
21 | }
22 | }
23 | },
24 | "events": []
25 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player_die.anim.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.0",
3 | "uuid": "deb66f55-f8ca-4db2-bc4e-ca33e6cb98ce",
4 | "subMetas": {}
5 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player_hunker.anim:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.AnimationClip",
3 | "_name": "player_hunker",
4 | "_objFlags": 0,
5 | "_rawFiles": null,
6 | "_duration": 1,
7 | "sample": 1,
8 | "speed": 1,
9 | "wrapMode": 1,
10 | "curveData": {
11 | "comps": {
12 | "cc.Sprite": {
13 | "spriteFrame": [
14 | {
15 | "frame": 0,
16 | "value": {
17 | "__uuid__": "07dbb373-78dd-44a3-a1a3-81e6bc444645"
18 | }
19 | }
20 | ]
21 | }
22 | }
23 | },
24 | "events": []
25 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player_hunker.anim.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.0",
3 | "uuid": "bf5e4641-c8f6-442c-aa1b-8ad807548c76",
4 | "subMetas": {}
5 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player_idle.anim:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.AnimationClip",
3 | "_name": "player_idle",
4 | "_objFlags": 0,
5 | "_rawFiles": null,
6 | "_duration": 0.016666666666666666,
7 | "sample": 60,
8 | "speed": 1,
9 | "wrapMode": 1,
10 | "curveData": {
11 | "comps": {
12 | "cc.Sprite": {
13 | "spriteFrame": [
14 | {
15 | "frame": 0,
16 | "value": {
17 | "__uuid__": "b1334959-77a3-4574-95ef-50803db2f5e0"
18 | }
19 | }
20 | ]
21 | }
22 | }
23 | },
24 | "events": []
25 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player_idle.anim.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.0",
3 | "uuid": "f0ee03ce-7867-4838-a381-800f70efa578",
4 | "subMetas": {}
5 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player_jump.anim:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.AnimationClip",
3 | "_name": "player_jump",
4 | "_objFlags": 0,
5 | "_rawFiles": null,
6 | "_duration": 1,
7 | "sample": 1,
8 | "speed": 1,
9 | "wrapMode": 1,
10 | "curveData": {
11 | "comps": {
12 | "cc.Sprite": {
13 | "spriteFrame": [
14 | {
15 | "frame": 0,
16 | "value": {
17 | "__uuid__": "b0cc33fa-eb0f-40b2-b10b-5099877cbad9"
18 | }
19 | }
20 | ]
21 | }
22 | }
23 | },
24 | "events": []
25 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player_jump.anim.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.0",
3 | "uuid": "b240e23c-3dfb-4bff-8328-424f697d80e3",
4 | "subMetas": {}
5 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player_run.anim:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.AnimationClip",
3 | "_name": "player_jump",
4 | "_objFlags": 0,
5 | "_rawFiles": null,
6 | "_duration": 1.3333333333333333,
7 | "sample": 3,
8 | "speed": 1,
9 | "wrapMode": 2,
10 | "curveData": {
11 | "comps": {
12 | "cc.Sprite": {
13 | "spriteFrame": [
14 | {
15 | "frame": 0,
16 | "value": {
17 | "__uuid__": "b1334959-77a3-4574-95ef-50803db2f5e0"
18 | }
19 | },
20 | {
21 | "frame": 0.3333333333333333,
22 | "value": {
23 | "__uuid__": "b0cc33fa-eb0f-40b2-b10b-5099877cbad9"
24 | }
25 | },
26 | {
27 | "frame": 0.6666666666666666,
28 | "value": {
29 | "__uuid__": "d82b1cab-bc84-49f5-ba82-883c2f7b23f4"
30 | }
31 | },
32 | {
33 | "frame": 1,
34 | "value": {
35 | "__uuid__": "5412a910-03fa-4a54-8820-c365a86d0ea0"
36 | }
37 | }
38 | ]
39 | }
40 | }
41 | },
42 | "events": []
43 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player_run.anim.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.0",
3 | "uuid": "766c94a6-03ff-47a7-9470-62e124fe3fa1",
4 | "subMetas": {}
5 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player_walk.anim:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.AnimationClip",
3 | "_name": "player_walk",
4 | "_objFlags": 0,
5 | "_rawFiles": null,
6 | "_duration": 0.875,
7 | "sample": 8,
8 | "speed": 0.8,
9 | "wrapMode": 2,
10 | "curveData": {
11 | "comps": {
12 | "cc.Sprite": {
13 | "spriteFrame": [
14 | {
15 | "frame": 0,
16 | "value": {
17 | "__uuid__": "fc2207d4-74d7-4f52-a37b-81b13821fc61"
18 | }
19 | },
20 | {
21 | "frame": 0.125,
22 | "value": {
23 | "__uuid__": "52b9ee83-b861-4add-a4af-a8769385a86e"
24 | }
25 | },
26 | {
27 | "frame": 0.25,
28 | "value": {
29 | "__uuid__": "73d7cc00-ad0a-4525-920d-42a7329ff8b5"
30 | }
31 | },
32 | {
33 | "frame": 0.375,
34 | "value": {
35 | "__uuid__": "b545d7a9-ca9f-4135-8ee1-612bbf9eb79f"
36 | }
37 | },
38 | {
39 | "frame": 0.5,
40 | "value": {
41 | "__uuid__": "d8bba4c2-a880-4592-98b6-efb5a3920fa1"
42 | }
43 | },
44 | {
45 | "frame": 0.625,
46 | "value": {
47 | "__uuid__": "045d8c05-b92b-49ce-82e0-649dc8ce560e"
48 | }
49 | },
50 | {
51 | "frame": 0.75,
52 | "value": {
53 | "__uuid__": "5412a910-03fa-4a54-8820-c365a86d0ea0"
54 | }
55 | }
56 | ]
57 | }
58 | }
59 | },
60 | "events": []
61 | }
--------------------------------------------------------------------------------
/assets/object/player/skin/rabbit/player_walk.anim.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.0",
3 | "uuid": "04c53391-7a36-4267-b7f0-596a644861b4",
4 | "subMetas": {}
5 | }
--------------------------------------------------------------------------------
/assets/object/snail.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "684c682b-a9b0-498c-98ca-62314c133fad",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/snail/snail_anim.anim:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.AnimationClip",
3 | "_name": "snail",
4 | "_objFlags": 0,
5 | "_rawFiles": null,
6 | "_duration": 1,
7 | "sample": 4,
8 | "speed": 0.8,
9 | "wrapMode": 2,
10 | "curveData": {
11 | "comps": {
12 | "cc.Sprite": {
13 | "spriteFrame": [
14 | {
15 | "frame": 0,
16 | "value": {
17 | "__uuid__": "aaba7764-92b5-479f-90c8-974e4d9a3624"
18 | }
19 | },
20 | {
21 | "frame": 0.25,
22 | "value": {
23 | "__uuid__": "0fbf7861-537b-4393-b6ad-6207f9810dbc"
24 | }
25 | },
26 | {
27 | "frame": 0.5,
28 | "value": {
29 | "__uuid__": "eb72dc33-eeaa-4136-9bde-b59c9b30bae4"
30 | }
31 | },
32 | {
33 | "frame": 0.75,
34 | "value": {
35 | "__uuid__": "aadf2899-d393-4da7-b038-9f2e55898df1"
36 | }
37 | }
38 | ]
39 | }
40 | }
41 | },
42 | "events": []
43 | }
--------------------------------------------------------------------------------
/assets/object/snail/snail_anim.anim.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.0",
3 | "uuid": "a813be53-37c3-4bfc-b084-9809d964951d",
4 | "subMetas": {}
5 | }
--------------------------------------------------------------------------------
/assets/object/snail/snail_anim2.anim:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.AnimationClip",
3 | "_name": "snaild",
4 | "_objFlags": 0,
5 | "_rawFiles": null,
6 | "_duration": 1,
7 | "sample": 1,
8 | "speed": 1,
9 | "wrapMode": 1,
10 | "curveData": {
11 | "comps": {
12 | "cc.Sprite": {
13 | "spriteFrame": [
14 | {
15 | "frame": 0,
16 | "value": {
17 | "__uuid__": "a0fcfe50-c264-444c-bf2c-0edc527924c7"
18 | }
19 | }
20 | ]
21 | }
22 | }
23 | },
24 | "events": []
25 | }
--------------------------------------------------------------------------------
/assets/object/snail/snail_anim2.anim.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.0",
3 | "uuid": "67cadff7-b4ed-451d-be62-103f18942d26",
4 | "subMetas": {}
5 | }
--------------------------------------------------------------------------------
/assets/object/snail/snail_block.prefab:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.Prefab",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "data": {
8 | "__id__": 1
9 | },
10 | "optimizationPolicy": 0,
11 | "asyncLoadAssets": false
12 | },
13 | {
14 | "__type__": "cc.Node",
15 | "_name": "snailBlock",
16 | "_objFlags": 0,
17 | "_parent": null,
18 | "_children": [],
19 | "_active": true,
20 | "_level": 1,
21 | "_components": [
22 | {
23 | "__id__": 2
24 | }
25 | ],
26 | "_prefab": {
27 | "__id__": 3
28 | },
29 | "_opacity": 0,
30 | "_color": {
31 | "__type__": "cc.Color",
32 | "r": 255,
33 | "g": 255,
34 | "b": 255,
35 | "a": 255
36 | },
37 | "_contentSize": {
38 | "__type__": "cc.Size",
39 | "width": 100,
40 | "height": 100
41 | },
42 | "_anchorPoint": {
43 | "__type__": "cc.Vec2",
44 | "x": 0,
45 | "y": 0
46 | },
47 | "_position": {
48 | "__type__": "cc.Vec3",
49 | "x": 0,
50 | "y": 0,
51 | "z": 0
52 | },
53 | "_scale": {
54 | "__type__": "cc.Vec3",
55 | "x": 1,
56 | "y": 1,
57 | "z": 1
58 | },
59 | "_rotationX": 0,
60 | "_rotationY": 0,
61 | "_quat": {
62 | "__type__": "cc.Quat",
63 | "x": 0,
64 | "y": 0,
65 | "z": 0,
66 | "w": 1
67 | },
68 | "_skewX": 0,
69 | "_skewY": 0,
70 | "groupIndex": 3,
71 | "_id": ""
72 | },
73 | {
74 | "__type__": "cc.Sprite",
75 | "_name": "",
76 | "_objFlags": 0,
77 | "node": {
78 | "__id__": 1
79 | },
80 | "_enabled": true,
81 | "_srcBlendFactor": 770,
82 | "_dstBlendFactor": 771,
83 | "_spriteFrame": {
84 | "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
85 | },
86 | "_type": 0,
87 | "_sizeMode": 0,
88 | "_fillType": 0,
89 | "_fillCenter": {
90 | "__type__": "cc.Vec2",
91 | "x": 0,
92 | "y": 0
93 | },
94 | "_fillStart": 0,
95 | "_fillRange": 0,
96 | "_isTrimmedMode": true,
97 | "_state": 0,
98 | "_atlas": null,
99 | "_id": ""
100 | },
101 | {
102 | "__type__": "cc.PrefabInfo",
103 | "root": {
104 | "__id__": 1
105 | },
106 | "asset": {
107 | "__uuid__": "f8fe0a90-e5e4-4233-b4f6-84319b11ce12"
108 | },
109 | "fileId": "d9CGSEuNpI9p1TXuVse/Pp",
110 | "sync": false
111 | }
112 | ]
--------------------------------------------------------------------------------
/assets/object/snail/snail_block.prefab.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "f8fe0a90-e5e4-4233-b4f6-84319b11ce12",
4 | "optimizationPolicy": "AUTO",
5 | "asyncLoadAssets": false,
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/snail/snail_node.prefab:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.Prefab",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "data": {
8 | "__id__": 1
9 | },
10 | "optimizationPolicy": 0,
11 | "asyncLoadAssets": false
12 | },
13 | {
14 | "__type__": "cc.Node",
15 | "_name": "snail",
16 | "_objFlags": 0,
17 | "_parent": null,
18 | "_children": [],
19 | "_active": true,
20 | "_level": 1,
21 | "_components": [
22 | {
23 | "__id__": 2
24 | },
25 | {
26 | "__id__": 3
27 | },
28 | {
29 | "__id__": 4
30 | },
31 | {
32 | "__id__": 5
33 | }
34 | ],
35 | "_prefab": {
36 | "__id__": 6
37 | },
38 | "_opacity": 255,
39 | "_color": {
40 | "__type__": "cc.Color",
41 | "r": 255,
42 | "g": 255,
43 | "b": 255,
44 | "a": 255
45 | },
46 | "_contentSize": {
47 | "__type__": "cc.Size",
48 | "width": 62,
49 | "height": 51
50 | },
51 | "_anchorPoint": {
52 | "__type__": "cc.Vec2",
53 | "x": 0.5,
54 | "y": 0
55 | },
56 | "_position": {
57 | "__type__": "cc.Vec3",
58 | "x": 345,
59 | "y": 159,
60 | "z": 0
61 | },
62 | "_scale": {
63 | "__type__": "cc.Vec3",
64 | "x": 1,
65 | "y": 1,
66 | "z": 1
67 | },
68 | "_rotationX": 0,
69 | "_rotationY": 0,
70 | "_quat": {
71 | "__type__": "cc.Quat",
72 | "x": 0,
73 | "y": 0,
74 | "z": 0,
75 | "w": 1
76 | },
77 | "_skewX": 0,
78 | "_skewY": 0,
79 | "groupIndex": 5,
80 | "_id": ""
81 | },
82 | {
83 | "__type__": "cc.Sprite",
84 | "_name": "",
85 | "_objFlags": 0,
86 | "node": {
87 | "__id__": 1
88 | },
89 | "_enabled": true,
90 | "_srcBlendFactor": 770,
91 | "_dstBlendFactor": 771,
92 | "_spriteFrame": {
93 | "__uuid__": "aaba7764-92b5-479f-90c8-974e4d9a3624"
94 | },
95 | "_type": 0,
96 | "_sizeMode": 1,
97 | "_fillType": 0,
98 | "_fillCenter": {
99 | "__type__": "cc.Vec2",
100 | "x": 0,
101 | "y": 0
102 | },
103 | "_fillStart": 0,
104 | "_fillRange": 0,
105 | "_isTrimmedMode": true,
106 | "_state": 0,
107 | "_atlas": {
108 | "__uuid__": "5fc256af-971a-4986-aa19-83036e2d4f43"
109 | },
110 | "_id": ""
111 | },
112 | {
113 | "__type__": "cc.Animation",
114 | "_name": "",
115 | "_objFlags": 0,
116 | "node": {
117 | "__id__": 1
118 | },
119 | "_enabled": true,
120 | "_defaultClip": {
121 | "__uuid__": "a813be53-37c3-4bfc-b084-9809d964951d"
122 | },
123 | "_clips": [
124 | {
125 | "__uuid__": "a813be53-37c3-4bfc-b084-9809d964951d"
126 | },
127 | {
128 | "__uuid__": "67cadff7-b4ed-451d-be62-103f18942d26"
129 | }
130 | ],
131 | "playOnLoad": true,
132 | "_id": ""
133 | },
134 | {
135 | "__type__": "cc.BoxCollider",
136 | "_name": "",
137 | "_objFlags": 0,
138 | "node": {
139 | "__id__": 1
140 | },
141 | "_enabled": true,
142 | "tag": 4,
143 | "_offset": {
144 | "__type__": "cc.Vec2",
145 | "x": 0,
146 | "y": 25
147 | },
148 | "_size": {
149 | "__type__": "cc.Size",
150 | "width": 62,
151 | "height": 51
152 | },
153 | "_id": ""
154 | },
155 | {
156 | "__type__": "552fcFmhY1FKY10JGh/6SMe",
157 | "_name": "",
158 | "_objFlags": 0,
159 | "node": {
160 | "__id__": 1
161 | },
162 | "_enabled": true,
163 | "speed": {
164 | "__type__": "cc.Vec2",
165 | "x": 40,
166 | "y": 0
167 | },
168 | "maxSpeed": {
169 | "__type__": "cc.Vec2",
170 | "x": 2000,
171 | "y": 2000
172 | },
173 | "scaleX": 1,
174 | "hurtNum": 0,
175 | "gravity": -1000,
176 | "isAlive": true,
177 | "canMove": true,
178 | "dieAudio": {
179 | "__uuid__": "6a2d22ca-e6d1-4207-8452-2ba2e5a43495"
180 | },
181 | "_id": ""
182 | },
183 | {
184 | "__type__": "cc.PrefabInfo",
185 | "root": {
186 | "__id__": 1
187 | },
188 | "asset": {
189 | "__uuid__": "667a14a5-9f66-46e5-95c9-46165fc33e2c"
190 | },
191 | "fileId": "09V8dem+lImJqI35qig8NH",
192 | "sync": false
193 | }
194 | ]
--------------------------------------------------------------------------------
/assets/object/snail/snail_node.prefab.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "667a14a5-9f66-46e5-95c9-46165fc33e2c",
4 | "optimizationPolicy": "AUTO",
5 | "asyncLoadAssets": false,
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/snail/snail_script.ts:
--------------------------------------------------------------------------------
1 | // Learn TypeScript:
2 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
3 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
4 | // Learn Attribute:
5 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
6 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
7 | // Learn life-cycle callbacks:
8 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
9 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
10 |
11 | const { ccclass, property } = cc._decorator;
12 |
13 | @ccclass
14 | export default class NewClass extends cc.Component {
15 |
16 | @property()
17 | speed: cc.Vec2 = new cc.Vec2(0, 0);
18 |
19 | @property()
20 | maxSpeed: cc.Vec2 = new cc.Vec2(0, 0);
21 |
22 | @property
23 | scaleX: number = 1;
24 |
25 | @property
26 | hurtNum: number = 0;
27 |
28 | @property
29 | gravity: number = -1000;
30 |
31 | @property
32 | isAlive: boolean = true;
33 |
34 | @property
35 | canMove: boolean = true;
36 |
37 | @property({type: cc.AudioClip})
38 | dieAudio: cc.AudioClip = null;
39 |
40 | touchingNumber: number = 0;
41 | anim: cc.Animation = null;
42 |
43 | // LIFE-CYCLE CALLBACKS:
44 |
45 | onLoad() {
46 | this.touchingNumber = 0;
47 | this.node.scaleX = 1;
48 | this.anim = this.getComponent(cc.Animation);
49 | }
50 |
51 | start() {
52 |
53 | }
54 |
55 | onCollisionEnter(other, self) {
56 | if (other.node.group == 'snailBlock') {
57 | // console.log('snailBlock.tag == 8');
58 | if (this.isAlive) {
59 | this.turn();
60 | this.speed.x = -this.speed.x;
61 | return;
62 | }
63 | }
64 |
65 | if (other.tag == 5)//木桩
66 | {
67 | this.touchingNumber++;
68 | this.speed.x = -this.speed.x;
69 | this.turn();
70 | // console.log('this.touchingNumber++: ' + this.touchingNumber++);
71 | }
72 |
73 |
74 | var otherAabb = other.world.aabb;
75 | var otherPreAabb = other.world.preAabb.clone();
76 |
77 | var selfAabb = self.world.aabb;
78 | var selfPreAabb = self.world.preAabb.clone();
79 | selfPreAabb.y = selfAabb.y;
80 | otherPreAabb.y = otherAabb.y;
81 |
82 | if (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
83 | if (selfPreAabb.yMax < otherPreAabb.yMax)// 兔子和蜗牛
84 | {
85 | if (other.node.group == 'player' && this.hurtNum == 0) {
86 | //cc.audioEngine.play(this.dieAudio, false, Global.volume);
87 | }
88 | this.hurtNum++;
89 | this.anim.play('snaild');
90 | // console.log('this.hurtNum===========' + this.hurtNum);
91 | if (this.hurtNum == 1) {
92 | this.canMove = false;
93 | this.isAlive = false;
94 | } else {
95 | this.canMove = true;
96 | this.speed.x = 500;
97 | }
98 | console.log('this.canMove: ' + this.canMove);
99 | }
100 | if (selfPreAabb.xMax > otherPreAabb.xMax) {
101 |
102 | this.turn();
103 | this.speed.x = -this.speed.x;
104 | }
105 | if (selfPreAabb.xMin < otherPreAabb.xMin) {
106 | this.turn();
107 | this.speed.x = -this.speed.x;
108 | }
109 |
110 | }
111 |
112 | if (cc.Intersection.rectRect(selfPreAabb, otherPreAabb)) {
113 | if (this.speed.y < 0 && (selfPreAabb.yMax > otherPreAabb.yMax)) {
114 | this.node.y = otherPreAabb.yMax - this.node.parent.y;
115 |
116 | }
117 | else if (this.speed.y > 0 && (selfPreAabb.yMin < otherPreAabb.yMin)) {
118 | this.node.y = otherPreAabb.yMin - selfPreAabb.height - this.node.parent.y;
119 | }
120 |
121 | this.speed.y = 0;
122 | }
123 | }
124 |
125 | onCollisionExit(other) {
126 |
127 | if (other.tag == 5) {
128 | this.touchingNumber--;
129 | }
130 | }
131 |
132 | update(dt) {
133 | // console.log('this.touchingNumber-----' + this.touchingNumber);
134 | if (this.canMove) {
135 | this.node.x -= this.speed.x * dt;
136 | }
137 | if (this.touchingNumber === 0) {
138 | this.speed.y += this.gravity * dt;
139 | if (Math.abs(this.speed.y) > this.maxSpeed.y) {
140 | this.speed.y = this.speed.y > 0 ? this.maxSpeed.y : -this.maxSpeed.y;
141 | }
142 | }
143 | this.node.y += this.speed.y * dt;
144 | }
145 |
146 | turn() {
147 | this.node.scaleX = -this.node.scaleX;
148 | }
149 |
150 | // update (dt) {}
151 | }
152 |
--------------------------------------------------------------------------------
/assets/object/snail/snail_script.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "552fc166-858d-4529-8d74-24687fe9231e",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/object/snail/snail_skin.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | frames
6 |
7 | snail_01.png
8 |
9 | aliases
10 |
11 | spriteOffset
12 | {0,0}
13 | spriteSize
14 | {62,51}
15 | spriteSourceSize
16 | {62,51}
17 | textureRect
18 | {{193,1},{62,51}}
19 | textureRotated
20 |
21 |
22 | snail_02.png
23 |
24 | aliases
25 |
26 | spriteOffset
27 | {0,0}
28 | spriteSize
29 | {62,53}
30 | spriteSourceSize
31 | {62,53}
32 | textureRect
33 | {{1,1},{62,53}}
34 | textureRotated
35 |
36 |
37 | snail_03.png
38 |
39 | aliases
40 |
41 | spriteOffset
42 | {0,0}
43 | spriteSize
44 | {62,52}
45 | spriteSourceSize
46 | {62,52}
47 | textureRect
48 | {{65,1},{62,52}}
49 | textureRotated
50 |
51 |
52 | snail_04.png
53 |
54 | aliases
55 |
56 | spriteOffset
57 | {0,0}
58 | spriteSize
59 | {62,52}
60 | spriteSourceSize
61 | {62,52}
62 | textureRect
63 | {{129,1},{62,52}}
64 | textureRotated
65 |
66 |
67 | snail_05.png
68 |
69 | aliases
70 |
71 | spriteOffset
72 | {0,0}
73 | spriteSize
74 | {43,43}
75 | spriteSourceSize
76 | {43,43}
77 | textureRect
78 | {{257,1},{43,43}}
79 | textureRotated
80 |
81 |
82 |
83 | metadata
84 |
85 | format
86 | 3
87 | pixelFormat
88 | RGBA8888
89 | premultiplyAlpha
90 |
91 | realTextureFileName
92 | snail_skin.png
93 | size
94 | {301,55}
95 | smartupdate
96 | $TexturePacker:SmartUpdate:88b1537427d2c1ecf6283e03fe199cd3:5e278a2540e079d9c5bd0a15c845053d:97ddf434755038fd5d6537df094ff554$
97 | textureFileName
98 | snail_skin.png
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/assets/object/snail/snail_skin.plist.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.2.4",
3 | "uuid": "5fc256af-971a-4986-aa19-83036e2d4f43",
4 | "rawTextureUuid": "11ee3410-656e-4c63-89db-fff6023bfb38",
5 | "size": {
6 | "width": 301,
7 | "height": 55
8 | },
9 | "type": "Texture Packer",
10 | "subMetas": {
11 | "snail_01.png": {
12 | "ver": "1.0.4",
13 | "uuid": "aaba7764-92b5-479f-90c8-974e4d9a3624",
14 | "rawTextureUuid": "11ee3410-656e-4c63-89db-fff6023bfb38",
15 | "trimType": "auto",
16 | "trimThreshold": 1,
17 | "rotated": false,
18 | "offsetX": 0,
19 | "offsetY": 0,
20 | "trimX": 193,
21 | "trimY": 1,
22 | "width": 62,
23 | "height": 51,
24 | "rawWidth": 62,
25 | "rawHeight": 51,
26 | "borderTop": 0,
27 | "borderBottom": 0,
28 | "borderLeft": 0,
29 | "borderRight": 0,
30 | "spriteType": "normal",
31 | "subMetas": {}
32 | },
33 | "snail_02.png": {
34 | "ver": "1.0.4",
35 | "uuid": "0fbf7861-537b-4393-b6ad-6207f9810dbc",
36 | "rawTextureUuid": "11ee3410-656e-4c63-89db-fff6023bfb38",
37 | "trimType": "auto",
38 | "trimThreshold": 1,
39 | "rotated": false,
40 | "offsetX": 0,
41 | "offsetY": 0,
42 | "trimX": 1,
43 | "trimY": 1,
44 | "width": 62,
45 | "height": 53,
46 | "rawWidth": 62,
47 | "rawHeight": 53,
48 | "borderTop": 0,
49 | "borderBottom": 0,
50 | "borderLeft": 0,
51 | "borderRight": 0,
52 | "spriteType": "normal",
53 | "subMetas": {}
54 | },
55 | "snail_03.png": {
56 | "ver": "1.0.4",
57 | "uuid": "eb72dc33-eeaa-4136-9bde-b59c9b30bae4",
58 | "rawTextureUuid": "11ee3410-656e-4c63-89db-fff6023bfb38",
59 | "trimType": "auto",
60 | "trimThreshold": 1,
61 | "rotated": false,
62 | "offsetX": 0,
63 | "offsetY": 0,
64 | "trimX": 65,
65 | "trimY": 1,
66 | "width": 62,
67 | "height": 52,
68 | "rawWidth": 62,
69 | "rawHeight": 52,
70 | "borderTop": 0,
71 | "borderBottom": 0,
72 | "borderLeft": 0,
73 | "borderRight": 0,
74 | "spriteType": "normal",
75 | "subMetas": {}
76 | },
77 | "snail_04.png": {
78 | "ver": "1.0.4",
79 | "uuid": "aadf2899-d393-4da7-b038-9f2e55898df1",
80 | "rawTextureUuid": "11ee3410-656e-4c63-89db-fff6023bfb38",
81 | "trimType": "auto",
82 | "trimThreshold": 1,
83 | "rotated": false,
84 | "offsetX": 0,
85 | "offsetY": 0,
86 | "trimX": 129,
87 | "trimY": 1,
88 | "width": 62,
89 | "height": 52,
90 | "rawWidth": 62,
91 | "rawHeight": 52,
92 | "borderTop": 0,
93 | "borderBottom": 0,
94 | "borderLeft": 0,
95 | "borderRight": 0,
96 | "spriteType": "normal",
97 | "subMetas": {}
98 | },
99 | "snail_05.png": {
100 | "ver": "1.0.4",
101 | "uuid": "a0fcfe50-c264-444c-bf2c-0edc527924c7",
102 | "rawTextureUuid": "11ee3410-656e-4c63-89db-fff6023bfb38",
103 | "trimType": "auto",
104 | "trimThreshold": 1,
105 | "rotated": false,
106 | "offsetX": 0,
107 | "offsetY": 0,
108 | "trimX": 257,
109 | "trimY": 1,
110 | "width": 43,
111 | "height": 43,
112 | "rawWidth": 43,
113 | "rawHeight": 43,
114 | "borderTop": 0,
115 | "borderBottom": 0,
116 | "borderLeft": 0,
117 | "borderRight": 0,
118 | "spriteType": "normal",
119 | "subMetas": {}
120 | }
121 | }
122 | }
--------------------------------------------------------------------------------
/assets/object/snail/snail_skin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/assets/object/snail/snail_skin.png
--------------------------------------------------------------------------------
/assets/object/snail/snail_skin.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.2.0",
3 | "uuid": "11ee3410-656e-4c63-89db-fff6023bfb38",
4 | "type": "sprite",
5 | "wrapMode": "clamp",
6 | "filterMode": "bilinear",
7 | "premultiplyAlpha": false,
8 | "subMetas": {
9 | "snail_skin": {
10 | "ver": "1.0.4",
11 | "uuid": "e17f4fa3-3ca9-4d66-8bd0-869609fd2301",
12 | "rawTextureUuid": "11ee3410-656e-4c63-89db-fff6023bfb38",
13 | "trimType": "auto",
14 | "trimThreshold": 1,
15 | "rotated": false,
16 | "offsetX": 0,
17 | "offsetY": 0,
18 | "trimX": 0,
19 | "trimY": 0,
20 | "width": 301,
21 | "height": 55,
22 | "rawWidth": 301,
23 | "rawHeight": 55,
24 | "borderTop": 0,
25 | "borderBottom": 0,
26 | "borderLeft": 0,
27 | "borderRight": 0,
28 | "subMetas": {}
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/assets/object/static.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "ae89f90b-cf9e-4177-b1d0-99399eecd7f9",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/static/empty_node.prefab:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.Prefab",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "data": {
8 | "__id__": 1
9 | },
10 | "optimizationPolicy": 0,
11 | "asyncLoadAssets": false
12 | },
13 | {
14 | "__type__": "cc.Node",
15 | "_name": "New Node",
16 | "_objFlags": 0,
17 | "_parent": null,
18 | "_children": [],
19 | "_active": true,
20 | "_level": 1,
21 | "_components": [
22 | {
23 | "__id__": 2
24 | }
25 | ],
26 | "_prefab": {
27 | "__id__": 3
28 | },
29 | "_opacity": 255,
30 | "_color": {
31 | "__type__": "cc.Color",
32 | "r": 255,
33 | "g": 255,
34 | "b": 255,
35 | "a": 255
36 | },
37 | "_contentSize": {
38 | "__type__": "cc.Size",
39 | "width": 2112,
40 | "height": 128
41 | },
42 | "_anchorPoint": {
43 | "__type__": "cc.Vec2",
44 | "x": 0.5,
45 | "y": 0.5
46 | },
47 | "_position": {
48 | "__type__": "cc.Vec3",
49 | "x": 0,
50 | "y": 0,
51 | "z": 0
52 | },
53 | "_scale": {
54 | "__type__": "cc.Vec3",
55 | "x": 1,
56 | "y": 1,
57 | "z": 1
58 | },
59 | "_rotationX": 0,
60 | "_rotationY": 0,
61 | "_quat": {
62 | "__type__": "cc.Quat",
63 | "x": 0,
64 | "y": 0,
65 | "z": 0,
66 | "w": 1
67 | },
68 | "_skewX": 0,
69 | "_skewY": 0,
70 | "groupIndex": 2,
71 | "_id": ""
72 | },
73 | {
74 | "__type__": "cc.Sprite",
75 | "_name": "",
76 | "_objFlags": 0,
77 | "node": {
78 | "__id__": 1
79 | },
80 | "_enabled": true,
81 | "_srcBlendFactor": 770,
82 | "_dstBlendFactor": 771,
83 | "_spriteFrame": null,
84 | "_type": 0,
85 | "_sizeMode": 1,
86 | "_fillType": 0,
87 | "_fillCenter": {
88 | "__type__": "cc.Vec2",
89 | "x": 0,
90 | "y": 0
91 | },
92 | "_fillStart": 0,
93 | "_fillRange": 0,
94 | "_isTrimmedMode": true,
95 | "_state": 0,
96 | "_atlas": null,
97 | "_id": ""
98 | },
99 | {
100 | "__type__": "cc.PrefabInfo",
101 | "root": {
102 | "__id__": 1
103 | },
104 | "asset": {
105 | "__uuid__": "222ab1d2-3c14-411a-a5c2-bf6cdee7cfc7"
106 | },
107 | "fileId": "27V9c23aJFJrPR1fHc9Idn",
108 | "sync": false
109 | }
110 | ]
--------------------------------------------------------------------------------
/assets/object/static/empty_node.prefab.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "222ab1d2-3c14-411a-a5c2-bf6cdee7cfc7",
4 | "optimizationPolicy": "AUTO",
5 | "asyncLoadAssets": false,
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/wall.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "2f4aa0fd-8eab-4bd2-8c67-0f3653cf9312",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/wall/wall_breakable_node.prefab:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.Prefab",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "data": {
8 | "__id__": 1
9 | },
10 | "optimizationPolicy": 0,
11 | "asyncLoadAssets": false
12 | },
13 | {
14 | "__type__": "cc.Node",
15 | "_name": "breakableWall",
16 | "_objFlags": 0,
17 | "_parent": null,
18 | "_children": [],
19 | "_active": true,
20 | "_level": 1,
21 | "_components": [
22 | {
23 | "__id__": 2
24 | },
25 | {
26 | "__id__": 3
27 | }
28 | ],
29 | "_prefab": {
30 | "__id__": 4
31 | },
32 | "_opacity": 255,
33 | "_color": {
34 | "__type__": "cc.Color",
35 | "r": 255,
36 | "g": 255,
37 | "b": 255,
38 | "a": 255
39 | },
40 | "_contentSize": {
41 | "__type__": "cc.Size",
42 | "width": 65,
43 | "height": 65
44 | },
45 | "_anchorPoint": {
46 | "__type__": "cc.Vec2",
47 | "x": 0.5,
48 | "y": 0.5
49 | },
50 | "_position": {
51 | "__type__": "cc.Vec3",
52 | "x": 0,
53 | "y": 0,
54 | "z": 0
55 | },
56 | "_scale": {
57 | "__type__": "cc.Vec3",
58 | "x": 1,
59 | "y": 1,
60 | "z": 1
61 | },
62 | "_rotationX": 0,
63 | "_rotationY": 0,
64 | "_quat": {
65 | "__type__": "cc.Quat",
66 | "x": 0,
67 | "y": 0,
68 | "z": 0,
69 | "w": 1
70 | },
71 | "_skewX": 0,
72 | "_skewY": 0,
73 | "groupIndex": 2,
74 | "_id": ""
75 | },
76 | {
77 | "__type__": "cc.Sprite",
78 | "_name": "",
79 | "_objFlags": 0,
80 | "node": {
81 | "__id__": 1
82 | },
83 | "_enabled": true,
84 | "_srcBlendFactor": 770,
85 | "_dstBlendFactor": 771,
86 | "_spriteFrame": {
87 | "__uuid__": "a3abd12c-4b6c-4a9a-91f1-215eb37b3b03"
88 | },
89 | "_type": 0,
90 | "_sizeMode": 1,
91 | "_fillType": 0,
92 | "_fillCenter": {
93 | "__type__": "cc.Vec2",
94 | "x": 0,
95 | "y": 0
96 | },
97 | "_fillStart": 0,
98 | "_fillRange": 0,
99 | "_isTrimmedMode": true,
100 | "_state": 0,
101 | "_atlas": null,
102 | "_id": ""
103 | },
104 | {
105 | "__type__": "cc.BoxCollider",
106 | "_name": "",
107 | "_objFlags": 0,
108 | "node": {
109 | "__id__": 1
110 | },
111 | "_enabled": true,
112 | "tag": 3,
113 | "_offset": {
114 | "__type__": "cc.Vec2",
115 | "x": 0,
116 | "y": 0
117 | },
118 | "_size": {
119 | "__type__": "cc.Size",
120 | "width": 65,
121 | "height": 65
122 | },
123 | "_id": ""
124 | },
125 | {
126 | "__type__": "cc.PrefabInfo",
127 | "root": {
128 | "__id__": 1
129 | },
130 | "asset": {
131 | "__uuid__": "284c81f1-de00-4a0a-b986-7cb915f1a143"
132 | },
133 | "fileId": "71Ni8EkR5LWL4QN3fbJ98m",
134 | "sync": false
135 | }
136 | ]
--------------------------------------------------------------------------------
/assets/object/wall/wall_breakable_node.prefab.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "284c81f1-de00-4a0a-b986-7cb915f1a143",
4 | "optimizationPolicy": "AUTO",
5 | "asyncLoadAssets": false,
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/wall/wall_breakable_skin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/assets/object/wall/wall_breakable_skin.png
--------------------------------------------------------------------------------
/assets/object/wall/wall_breakable_skin.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.2.0",
3 | "uuid": "ccb8cd5e-c6e9-40d7-ba9f-3dc3785c39e9",
4 | "type": "sprite",
5 | "wrapMode": "clamp",
6 | "filterMode": "bilinear",
7 | "premultiplyAlpha": false,
8 | "subMetas": {
9 | "wall_breakable_skin": {
10 | "ver": "1.0.4",
11 | "uuid": "a3abd12c-4b6c-4a9a-91f1-215eb37b3b03",
12 | "rawTextureUuid": "ccb8cd5e-c6e9-40d7-ba9f-3dc3785c39e9",
13 | "trimType": "auto",
14 | "trimThreshold": 1,
15 | "rotated": false,
16 | "offsetX": 0,
17 | "offsetY": 0,
18 | "trimX": 0,
19 | "trimY": 0,
20 | "width": 65,
21 | "height": 65,
22 | "rawWidth": 65,
23 | "rawHeight": 65,
24 | "borderTop": 0,
25 | "borderBottom": 0,
26 | "borderLeft": 0,
27 | "borderRight": 0,
28 | "subMetas": {}
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/assets/object/wall/wall_node.prefab:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.Prefab",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "data": {
8 | "__id__": 1
9 | },
10 | "optimizationPolicy": 0,
11 | "asyncLoadAssets": false
12 | },
13 | {
14 | "__type__": "cc.Node",
15 | "_name": "bonusWall",
16 | "_objFlags": 0,
17 | "_parent": null,
18 | "_children": [],
19 | "_active": true,
20 | "_level": 1,
21 | "_components": [
22 | {
23 | "__id__": 2
24 | },
25 | {
26 | "__id__": 3
27 | }
28 | ],
29 | "_prefab": {
30 | "__id__": 4
31 | },
32 | "_opacity": 255,
33 | "_color": {
34 | "__type__": "cc.Color",
35 | "r": 255,
36 | "g": 255,
37 | "b": 255,
38 | "a": 255
39 | },
40 | "_contentSize": {
41 | "__type__": "cc.Size",
42 | "width": 64,
43 | "height": 65
44 | },
45 | "_anchorPoint": {
46 | "__type__": "cc.Vec2",
47 | "x": 0.5,
48 | "y": 0.5
49 | },
50 | "_position": {
51 | "__type__": "cc.Vec3",
52 | "x": 0,
53 | "y": 0,
54 | "z": 0
55 | },
56 | "_scale": {
57 | "__type__": "cc.Vec3",
58 | "x": 1,
59 | "y": 1,
60 | "z": 1
61 | },
62 | "_rotationX": 0,
63 | "_rotationY": 0,
64 | "_quat": {
65 | "__type__": "cc.Quat",
66 | "x": 0,
67 | "y": 0,
68 | "z": 0,
69 | "w": 1
70 | },
71 | "_skewX": 0,
72 | "_skewY": 0,
73 | "groupIndex": 2,
74 | "_id": ""
75 | },
76 | {
77 | "__type__": "cc.Sprite",
78 | "_name": "",
79 | "_objFlags": 0,
80 | "node": {
81 | "__id__": 1
82 | },
83 | "_enabled": true,
84 | "_srcBlendFactor": 770,
85 | "_dstBlendFactor": 771,
86 | "_spriteFrame": {
87 | "__uuid__": "3bdc6a63-9b4f-44dc-9791-c3045ae2cc61"
88 | },
89 | "_type": 0,
90 | "_sizeMode": 1,
91 | "_fillType": 0,
92 | "_fillCenter": {
93 | "__type__": "cc.Vec2",
94 | "x": 0,
95 | "y": 0
96 | },
97 | "_fillStart": 0,
98 | "_fillRange": 0,
99 | "_isTrimmedMode": false,
100 | "_state": 0,
101 | "_atlas": null,
102 | "_id": ""
103 | },
104 | {
105 | "__type__": "f14a0DxgXtGX64eBzym58v0",
106 | "_name": "",
107 | "_objFlags": 0,
108 | "node": {
109 | "__id__": 1
110 | },
111 | "_enabled": true,
112 | "CoinJump": {
113 | "__uuid__": "f0a27f46-5b77-4fce-8986-70a1268c268e"
114 | },
115 | "mushroom": {
116 | "__uuid__": "d67a786a-3613-470f-824e-6aa547e0af00"
117 | },
118 | "isCollisionable": true,
119 | "_id": ""
120 | },
121 | {
122 | "__type__": "cc.PrefabInfo",
123 | "root": {
124 | "__id__": 1
125 | },
126 | "asset": {
127 | "__uuid__": "f985b01c-b043-4180-b11c-8a043045303d"
128 | },
129 | "fileId": "96m6MLyXtHzItau98quS9h",
130 | "sync": false
131 | }
132 | ]
--------------------------------------------------------------------------------
/assets/object/wall/wall_node.prefab.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "f985b01c-b043-4180-b11c-8a043045303d",
4 | "optimizationPolicy": "AUTO",
5 | "asyncLoadAssets": false,
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/object/wall/wall_skin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/assets/object/wall/wall_skin.png
--------------------------------------------------------------------------------
/assets/object/wall/wall_skin.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.2.0",
3 | "uuid": "58b5bd9b-6ba9-42e3-9ab5-1b1284f3d893",
4 | "type": "sprite",
5 | "wrapMode": "clamp",
6 | "filterMode": "bilinear",
7 | "premultiplyAlpha": false,
8 | "subMetas": {
9 | "wall_skin": {
10 | "ver": "1.0.4",
11 | "uuid": "3bdc6a63-9b4f-44dc-9791-c3045ae2cc61",
12 | "rawTextureUuid": "58b5bd9b-6ba9-42e3-9ab5-1b1284f3d893",
13 | "trimType": "auto",
14 | "trimThreshold": 1,
15 | "rotated": false,
16 | "offsetX": 0,
17 | "offsetY": 0,
18 | "trimX": 0,
19 | "trimY": 0,
20 | "width": 64,
21 | "height": 65,
22 | "rawWidth": 64,
23 | "rawHeight": 65,
24 | "borderTop": 0,
25 | "borderBottom": 0,
26 | "borderLeft": 0,
27 | "borderRight": 0,
28 | "subMetas": {}
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/assets/scene.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "4a7c8ffe-245c-49db-983d-dbe2e041dca0",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/scene/game.fire.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "18362f9d-6d23-4bd0-a977-c8dab28cb836",
4 | "asyncLoadAssets": false,
5 | "autoReleaseAssets": false,
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/script.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "e1eb56fe-7cc8-4625-a475-db33895afd50",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/script/lookat.ts:
--------------------------------------------------------------------------------
1 | // Learn TypeScript:
2 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
3 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
4 | // Learn Attribute:
5 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
6 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
7 | // Learn life-cycle callbacks:
8 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
9 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
10 |
11 | const { ccclass, property } = cc._decorator;
12 |
13 | @ccclass
14 | export default class NewClass extends cc.Component {
15 |
16 | @property(cc.Node)
17 | target: cc.Node = null;
18 |
19 | @property(cc.Node)
20 | map: cc.Node = null;
21 |
22 | boundingBox: cc.Rect = null;
23 | screenMiddle: cc.Vec2 = null;
24 |
25 | minX: number = 0;
26 | maxX: number = 0;
27 | minY: number = 0;
28 | maxY: number = 0;
29 |
30 | isRun: boolean = true;
31 |
32 | // LIFE-CYCLE CALLBACKS:
33 |
34 | onLoad() {
35 | this.boundingBox = new cc.Rect(0, 0, this.map.width, this.map.height);
36 | let winsize = cc.winSize;
37 | this.screenMiddle = new cc.Vec2(winsize.width / 2, winsize.height / 2);
38 | this.minX = -(this.boundingBox.xMax - winsize.width);
39 | this.maxX = this.boundingBox.xMin;
40 | this.minY = -(this.boundingBox.yMax - winsize.height);
41 | this.maxY = this.boundingBox.yMin;
42 | }
43 |
44 | update() {
45 | if (!this.isRun)
46 | return;
47 |
48 | //将一个点转换到世界空间坐标系。结果以 Vec2 为单位。
49 | let pos = this.node.convertToWorldSpaceAR(cc.Vec2.ZERO);
50 | // console.log('pos:'+pos);
51 | let targertPos = this.target.convertToWorldSpaceAR(cc.Vec2.ZERO);
52 | // console.log('targertPos:'+targertPos);
53 | let dis = pos.sub(targertPos);
54 | // console.log('dis:'+dis);
55 | let dest = this.screenMiddle.add(dis);
56 | // console.log('dest:'+dest);
57 | dest.x = cc.misc.clampf(dest.x, this.minX, this.maxX);//限定dest.x的最大最小值。
58 | dest.y = this.minY;
59 | // dest.y = cc.clampf(dest.y, this.minY, this.maxY);
60 | this.node.position = this.node.parent.convertToNodeSpaceAR(dest);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/assets/script/lookat.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "30aee514-732b-4ce9-9807-249c61374457",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/script/main.ts:
--------------------------------------------------------------------------------
1 | // Learn TypeScript:
2 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
3 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
4 | // Learn Attribute:
5 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
6 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
7 | // Learn life-cycle callbacks:
8 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
9 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
10 |
11 | const {ccclass, property} = cc._decorator;
12 |
13 | @ccclass
14 | export default class NewClass extends cc.Component {
15 |
16 | @property(cc.Label)
17 | label: cc.Label = null;
18 |
19 | @property
20 | text: string = 'hello';
21 |
22 | // LIFE-CYCLE CALLBACKS:
23 |
24 | // onLoad () {}
25 |
26 | start () {
27 |
28 | }
29 |
30 | // update (dt) {}
31 | }
32 |
--------------------------------------------------------------------------------
/assets/script/main.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "606466e8-890d-41f7-96a3-6f2ed8ad708d",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/script/player.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "326b86fa-94e1-4758-bcc5-3da73596b372",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/script/world.ts:
--------------------------------------------------------------------------------
1 | // Learn TypeScript:
2 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
3 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
4 | // Learn Attribute:
5 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
6 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
7 | // Learn life-cycle callbacks:
8 | // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
9 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
10 |
11 | const {ccclass, property} = cc._decorator;
12 |
13 | @ccclass
14 | export default class CWorld extends cc.Component {
15 |
16 | @property()
17 | WorldFallG: number = 0;
18 |
19 | @property()
20 | WorldWalkA: number = 0;
21 |
22 | static G: number = 0;
23 | static WalkA: number = 0;
24 | static GiveCoin: number = 0;
25 | static AddSpeed: number = 1;
26 |
27 | // LIFE-CYCLE CALLBACKS:
28 |
29 | onLoad () {
30 | CWorld.G = this.WorldFallG;
31 | CWorld.WalkA = this.WorldWalkA;
32 | }
33 |
34 | start () {
35 | cc.director.getCollisionManager().enabled = true;
36 | cc.director.getCollisionManager().enabledDebugDraw = true;
37 | cc.director.getCollisionManager().enabledDrawBoundingBox = true;
38 | }
39 |
40 | // update (dt) {}
41 | }
42 |
--------------------------------------------------------------------------------
/assets/script/world.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "d380f1fe-6c3e-475e-b35d-d5ceb1a428d4",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/script/worldmap.ts:
--------------------------------------------------------------------------------
1 | // Learn TypeScript:
2 | // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/typescript.html
3 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
4 | // Learn Attribute:
5 | // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
6 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
7 | // Learn life-cycle callbacks:
8 | // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
9 | // - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
10 |
11 | const { ccclass, property } = cc._decorator;
12 |
13 | @ccclass
14 | export default class CMap extends cc.Component {
15 |
16 | @property(cc.TiledMap)
17 | worldMap: cc.TiledMap = null;
18 |
19 | @property(cc.Node)
20 | worldPlayer: cc.Node = null;
21 |
22 | @property
23 | PointsName: string = 'points';
24 |
25 | @property
26 | playerName: string = 'player';
27 |
28 | @property
29 | finishName: string = 'finish';
30 |
31 | @property
32 | Wall: string = 'wall';
33 |
34 | @property
35 | Ground: string = 'ground';
36 |
37 | @property
38 | destroyable_blocksName: string = 'destroyable_blocks';
39 |
40 | @property
41 | bonus_blocksName: string = 'bonus_blocks';
42 |
43 | @property
44 | CoinsName: string = 'coins';
45 |
46 | @property
47 | enemyName: string = 'enemies';
48 |
49 | @property
50 | floorLayerName: string = 'floor';
51 |
52 | @property
53 | waterLayerName: string = 'water';
54 |
55 | @property
56 | CollisionsGroupName: string = 'physics';
57 |
58 | @property
59 | snailBlockName: string = 'snailBlock';
60 |
61 | @property(cc.Prefab)
62 | CoinsPre: cc.Prefab = null;
63 |
64 | @property(cc.Prefab)
65 | ColliderPreName: cc.Prefab = null;
66 |
67 | @property(cc.Prefab)
68 | breakableWallPre: cc.Prefab = null;
69 |
70 | @property(cc.Prefab)
71 | bonusWallPre: cc.Prefab = null;
72 |
73 | @property(cc.Prefab)
74 | enemyBeetle: cc.Prefab = null;
75 |
76 | @property(cc.Prefab)
77 | enemySnail: cc.Prefab = null;
78 |
79 | @property(cc.Prefab)
80 | castle_finish: cc.Prefab = null;
81 |
82 | @property(cc.Prefab)
83 | snailBlockPre: cc.Prefab = null;
84 |
85 | // LIFE-CYCLE CALLBACKS:
86 |
87 | onLoad () {
88 |
89 | }
90 |
91 | start() {
92 | var _layerFloor: cc.TiledLayer = this.worldMap.getLayer(this.floorLayerName);
93 | if (!_layerFloor) return;
94 |
95 | var startPoint = this.worldMap.getObjectGroup(this.playerName);
96 | var endPoint = this.worldMap.getObjectGroup(this.finishName);
97 | var coinPoints = this.worldMap.getObjectGroup(this.CoinsName);
98 | var collisionPoints = this.worldMap.getObjectGroup(this.CollisionsGroupName);
99 | var destroyable_blocks = this.worldMap.getObjectGroup(this.destroyable_blocksName);
100 | var bonus_blocks = this.worldMap.getObjectGroup(this.bonus_blocksName);
101 | var enemies = this.worldMap.getObjectGroup(this.enemyName);
102 | var waters = this.worldMap.getObjectGroup(this.waterLayerName);
103 | var finish = this.worldMap.getObjectGroup(this.finishName);
104 | var snailBlocks = this.worldMap.getObjectGroup(this.snailBlockName);
105 | var finishPoint = finish.getObject('finishPoint');
106 |
107 | var castle_finish = cc.instantiate(this.castle_finish);
108 | castle_finish.x = finishPoint.x;
109 | castle_finish.y = finishPoint.y + 200;
110 | this.node.addChild(castle_finish);
111 |
112 | if (!startPoint || !endPoint)
113 | return;
114 |
115 | for (var i = 1; i < 3; i++) {
116 | var snailBlockName = 'snailBlock' + i;
117 | var snailBlock = snailBlocks.getObject(snailBlockName);
118 | var snailBlockNode = cc.instantiate(this.snailBlockPre);
119 | snailBlockNode.width = snailBlock.width;
120 | snailBlockNode.height = snailBlock.height;
121 | snailBlockNode.x = snailBlock.x;
122 | snailBlockNode.y = snailBlock.y - snailBlock.height;
123 | snailBlockNode.addComponent(cc.BoxCollider);
124 | snailBlockNode.getComponent(cc.BoxCollider).size = cc.size(snailBlockNode.width, snailBlockNode.height);
125 | snailBlockNode.getComponent(cc.BoxCollider).offset = new cc.Vec2(snailBlockNode.width / 2, -snailBlockNode.height / 2);
126 | snailBlockNode.getComponent(cc.BoxCollider).tag = 9;
127 | this.node.addChild(snailBlockNode);
128 |
129 | }
130 | for (var i = 1; i < 8; i++) {
131 | var waterName = 'water' + i;
132 | var waterBlock = waters.getObject(waterName);
133 | var waterNode = cc.instantiate(this.ColliderPreName);
134 | waterNode.group = 'water';
135 | waterNode.width = waterBlock.width;
136 | waterNode.height = waterBlock.height;
137 | waterNode.x = waterBlock.x;
138 | waterNode.y = waterBlock.y - waterBlock.height;
139 | waterNode.addComponent(cc.BoxCollider);
140 | waterNode.getComponent(cc.BoxCollider).size = cc.size(waterNode.width, waterNode.height);
141 | waterNode.getComponent(cc.BoxCollider).offset = new cc.Vec2(waterNode.width / 2, -waterNode.height / 2);
142 | console.log('waterBlock.height: ' + waterBlock.height);
143 | waterNode.getComponent(cc.BoxCollider).tag = 6;
144 | this.node.addChild(waterNode);
145 | }
146 | for (var i = 1; i < 17; i++) {
147 | var enemyName = 'enemy' + i;
148 | var enemyBlock = enemies.getObject(enemyName);
149 | if (5 == i || 9 == i) {
150 | var enemy = cc.instantiate(this.enemySnail);
151 | }
152 | else
153 | var enemy = cc.instantiate(this.enemyBeetle);
154 | enemy.x = enemyBlock.x;
155 | enemy.y = enemyBlock.y;
156 | this.node.addChild(enemy);
157 |
158 | }
159 | for (var i = 1; i < 30; i++) {
160 | var destroyable_blockName = 'destroyable_blocks' + i;
161 | var destroyable_block = destroyable_blocks.getObject(destroyable_blockName);
162 | var breakableWall = cc.instantiate(this.breakableWallPre);
163 | breakableWall.x = destroyable_block.x;
164 | breakableWall.y = destroyable_block.y;
165 | this.node.addChild(breakableWall);
166 | }
167 | for (var i = 1; i < 7; i++) {
168 | var bonus_blockName = 'bonus_block' + i;
169 | var bonus_block = bonus_blocks.getObject(bonus_blockName);
170 | var bonusWall: cc.Node = cc.instantiate(this.bonusWallPre);
171 | bonusWall.zIndex = 99;
172 | bonusWall.x = bonus_block.x;
173 | bonusWall.y = bonus_block.y;
174 | if (bonus_block.name == 'bonus_block4') {
175 | bonusWall.getComponent(cc.BoxCollider).tag = 7;
176 | }
177 | this.node.addChild(bonusWall);
178 | }
179 | for (var i = 1; i < 40; i++) {
180 | var coinName = 'coin' + i;
181 | var coinPoint = coinPoints.getObject(coinName);
182 | var coin = cc.instantiate(this.CoinsPre);
183 | coin.x = coinPoint.x;
184 | // coin.height = coinNode.height;
185 | coin.y = coinPoint.y;
186 | this.node.addChild(coin);
187 | }
188 | for (var i = 1; i < 31; i++) {
189 | // this.collisionName[i] = i.toString();
190 | var collisionName = i.toString();
191 | var collider = collisionPoints.getObject(collisionName);
192 | var node = cc.instantiate(this.ColliderPreName);
193 | // var node = new cc.Node();
194 | node.setAnchorPoint(0.5, 0.5);
195 | node.x = collider.x;
196 | node.height = collider.height;
197 | node.y = collider.y - collider.height;
198 | node.width = collider.width;
199 | node.addComponent(cc.BoxCollider);
200 | node.getComponent(cc.BoxCollider).size = cc.size(collider.width, collider.height);
201 | node.getComponent(cc.BoxCollider).offset = cc.v2(collider.width / 2, collider.height / 2);
202 | node.getComponent(cc.BoxCollider).tag = 5;
203 | this.node.addChild(node);
204 | }
205 | }
206 | }
207 |
--------------------------------------------------------------------------------
/assets/script/worldmap.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.5",
3 | "uuid": "023b142e-d6cc-469a-983f-f6e5912bf94b",
4 | "isPlugin": false,
5 | "loadPluginInWeb": true,
6 | "loadPluginInNative": true,
7 | "loadPluginInEditor": false,
8 | "subMetas": {}
9 | }
--------------------------------------------------------------------------------
/assets/sound.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "31929c40-5edd-47ed-a443-ba252e93ae46",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/sound/enemy_killed.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/assets/sound/enemy_killed.mp3
--------------------------------------------------------------------------------
/assets/sound/enemy_killed.mp3.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.0.0",
3 | "uuid": "6a2d22ca-e6d1-4207-8452-2ba2e5a43495",
4 | "downloadMode": 0,
5 | "subMetas": {}
6 | }
--------------------------------------------------------------------------------
/assets/texture.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.1",
3 | "uuid": "06ed6b43-b49a-4413-80a0-1c93021ec9c8",
4 | "isSubpackage": false,
5 | "subpackageName": "",
6 | "subMetas": {}
7 | }
--------------------------------------------------------------------------------
/assets/texture/gamebg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/assets/texture/gamebg.png
--------------------------------------------------------------------------------
/assets/texture/gamebg.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "2.2.0",
3 | "uuid": "1a198050-3166-482d-aa27-7ee3a63c1182",
4 | "type": "sprite",
5 | "wrapMode": "clamp",
6 | "filterMode": "bilinear",
7 | "premultiplyAlpha": false,
8 | "subMetas": {
9 | "gamebg": {
10 | "ver": "1.0.4",
11 | "uuid": "8fc82a77-5ecc-4bf3-9c88-ffb69563956f",
12 | "rawTextureUuid": "1a198050-3166-482d-aa27-7ee3a63c1182",
13 | "trimType": "auto",
14 | "trimThreshold": 1,
15 | "rotated": false,
16 | "offsetX": 0,
17 | "offsetY": 0,
18 | "trimX": 0,
19 | "trimY": 0,
20 | "width": 1024,
21 | "height": 512,
22 | "rawWidth": 1024,
23 | "rawHeight": 512,
24 | "borderTop": 0,
25 | "borderBottom": 0,
26 | "borderLeft": 0,
27 | "borderRight": 0,
28 | "subMetas": {}
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es6",
4 | "module": "commonjs",
5 | "experimentalDecorators": true
6 | },
7 | "exclude": [
8 | "node_modules",
9 | ".vscode",
10 | "library",
11 | "local",
12 | "settings",
13 | "temp"
14 | ]
15 | }
--------------------------------------------------------------------------------
/md/014B076F-900E-44D4-AEEE-7692B34B97B9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/md/014B076F-900E-44D4-AEEE-7692B34B97B9.png
--------------------------------------------------------------------------------
/md/0F978144-7A1C-4C90-9C9E-386285F69747.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/md/0F978144-7A1C-4C90-9C9E-386285F69747.png
--------------------------------------------------------------------------------
/md/239F9545-E5BE-4751-AC87-6EACCBD51FD1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/md/239F9545-E5BE-4751-AC87-6EACCBD51FD1.png
--------------------------------------------------------------------------------
/md/D99BE452-D17D-4C69-B6B6-106797270656.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/md/D99BE452-D17D-4C69-B6B6-106797270656.png
--------------------------------------------------------------------------------
/md/EDE465D0-92A2-4D7D-A06D-00BFBDE0B393.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/md/EDE465D0-92A2-4D7D-A06D-00BFBDE0B393.png
--------------------------------------------------------------------------------
/md/image-20190731111104819.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/md/image-20190731111104819.png
--------------------------------------------------------------------------------
/md/image-20190731141951163.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/md/image-20190731141951163.png
--------------------------------------------------------------------------------
/md/image-20190731170024369.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/md/image-20190731170024369.png
--------------------------------------------------------------------------------
/md/image-20190731170101522.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/md/image-20190731170101522.png
--------------------------------------------------------------------------------
/md/image-20190731172137708.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/md/image-20190731172137708.png
--------------------------------------------------------------------------------
/md/image-20190731172239417.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/md/image-20190731172239417.png
--------------------------------------------------------------------------------
/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "engine": "cocos2d-html5",
3 | "packages": "packages"
4 | }
--------------------------------------------------------------------------------
/settings/builder.json:
--------------------------------------------------------------------------------
1 | {
2 | "android-instant": {
3 | "REMOTE_SERVER_ROOT": "",
4 | "host": "",
5 | "pathPattern": "",
6 | "recordPath": "",
7 | "scheme": "https",
8 | "skipRecord": false
9 | },
10 | "appBundle": false,
11 | "baidugame": {
12 | "REMOTE_SERVER_ROOT": "",
13 | "appid": "testappid",
14 | "orientation": "portrait",
15 | "subContext": ""
16 | },
17 | "encryptJs": true,
18 | "excludeScenes": [],
19 | "fb-instant-games": {},
20 | "includeSDKBox": false,
21 | "inlineSpriteFrames": true,
22 | "inlineSpriteFrames_native": true,
23 | "md5Cache": false,
24 | "mergeStartScene": false,
25 | "optimizeHotUpdate": false,
26 | "orientation": {
27 | "landscapeLeft": true,
28 | "landscapeRight": true,
29 | "portrait": false,
30 | "upsideDown": false
31 | },
32 | "packageName": "org.cocos2d.helloworld",
33 | "qqplay": {
34 | "REMOTE_SERVER_ROOT": "",
35 | "orientation": "portrait",
36 | "zip": false
37 | },
38 | "startScene": "18362f9d-6d23-4bd0-a977-c8dab28cb836",
39 | "title": "hello_world",
40 | "webOrientation": "auto",
41 | "wechatgame": {
42 | "REMOTE_SERVER_ROOT": "",
43 | "appid": "wx6ac3f5090a6b99c5",
44 | "orientation": "portrait",
45 | "separate_engine": false,
46 | "subContext": ""
47 | },
48 | "xxteaKey": "9bfe4bf3-6228-41",
49 | "zipCompressJs": true
50 | }
--------------------------------------------------------------------------------
/settings/builder.panel.json:
--------------------------------------------------------------------------------
1 | {
2 | "excludeScenes": [],
3 | "packageName": "org.cocos2d.helloworld",
4 | "platform": "web-mobile",
5 | "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
6 | "title": "HelloWorld"
7 | }
--------------------------------------------------------------------------------
/settings/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "collision-matrix": [
3 | [
4 | true
5 | ],
6 | [
7 | false,
8 | false,
9 | true,
10 | null,
11 | true,
12 | true,
13 | true,
14 | true
15 | ],
16 | [
17 | false,
18 | true,
19 | false,
20 | null,
21 | null,
22 | true,
23 | null,
24 | true
25 | ],
26 | [
27 | false,
28 | false,
29 | false,
30 | false,
31 | null,
32 | true
33 | ],
34 | [
35 | false,
36 | true,
37 | false,
38 | false,
39 | false
40 | ],
41 | [
42 | false,
43 | true,
44 | true,
45 | true,
46 | false,
47 | true
48 | ],
49 | [
50 | false,
51 | true,
52 | false,
53 | false,
54 | false,
55 | false,
56 | false
57 | ],
58 | [
59 | false,
60 | true,
61 | true,
62 | false,
63 | false,
64 | false,
65 | false,
66 | false
67 | ]
68 | ],
69 | "design-resolution-height": 640,
70 | "design-resolution-width": 960,
71 | "excluded-modules": [],
72 | "fit-height": true,
73 | "fit-width": false,
74 | "group-list": [
75 | "default",
76 | "player",
77 | "platform",
78 | "snailBlock",
79 | "coin",
80 | "enemy",
81 | "water",
82 | "mushroom"
83 | ],
84 | "simulator-orientation": false,
85 | "simulator-resolution": {
86 | "height": 640,
87 | "width": 960
88 | },
89 | "use-customize-simulator": true,
90 | "use-project-simulator-setting": false,
91 | "start-scene": "current",
92 | "last-module-event-record-time": 0,
93 | "assets-sort-type": "name",
94 | "facebook": {
95 | "enable": false,
96 | "appID": "",
97 | "live": {
98 | "enable": false
99 | },
100 | "audience": {
101 | "enable": false
102 | }
103 | }
104 | }
--------------------------------------------------------------------------------
/settings/services.json:
--------------------------------------------------------------------------------
1 | {
2 | "services": [
3 | {
4 | "service_id": "242",
5 | "service_name": "Agora Voice",
6 | "service_icon": "https://account.cocos.com/uploads/client_icon/2019-07-16/273952d155b4cdb72d2b1bc61de91ade.png",
7 | "service_desc": "Build the future of communications with the world’s leading voice、video、and interactive broadcasting platform. Agora delivers easy to embed Real-Time Engagement APIs which includes all the development tools and cloud infrastructure needed for mobile、web、and desktop applications.",
8 | "service_title": "SDKBuilt-in real-time Audio SDK",
9 | "service_guide_url": "https://docs.agora.io/en/Interactive Gaming/game_c?platform=Cocos Creator",
10 | "service_sample_url": "https://github.com/AgoraIO/Voice-Call-for-Mobile-Gaming/tree/master/Basic-Voice-Call-for-Gaming/Hello-CocosCreator-Voice-Agora",
11 | "service_dev_url": "https://sso.agora.io/api/oauth/cocos/login",
12 | "service_type": "3",
13 | "service_type_zh": "公司和个人游戏",
14 | "support_platform": [
15 | "Android",
16 | "iOS",
17 | "HTML5"
18 | ],
19 | "package_download_url": "http://download.cocos.com/CocosServices/plugins/service-agora/1.0.2_2.2.3.20_2.5.2.zip",
20 | "package_version_desc": "解决Bug:onAudioVolumeIndication 回调收不到.",
21 | "service_component_name": "service-agora",
22 | "package_versions": [
23 | "1.0.1_2.2.3.20_2.5.2",
24 | "1.0.2_2.2.3.20_2.5.2"
25 | ],
26 | "build_platform": [
27 | "web-mobile",
28 | "web-desktop",
29 | "android",
30 | "ios"
31 | ],
32 | "require_verify": 1,
33 | "service_price": "The service according to usage billing, billing rules ,the fees incurred by the third party from your Cocos balances .",
34 | "packpage_version_desc": "",
35 | "service_protocol": "Game for the first time to open the service,the Cocos after notification service for game on service and initialization parameters,service party may according to need to get your Cocos account information,such as account basic information,game basic information,account balance,click on the confirm open button that is seen as you agree to the service to access your account information,See < a href='http://auth.cocos.com/CocosServiceAgreement.html'>Cocos user service agreement and Cocos privacy policy "
36 | }
37 | ],
38 | "game": {
39 | "name": "UNKNOW GAME",
40 | "appid": "UNKNOW"
41 | }
42 | }
--------------------------------------------------------------------------------
/template-banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xianyinchen/creator_teach/7f21f308bf4656fb8247f6020b6c8776222e1b7d/template-banner.png
--------------------------------------------------------------------------------
/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "TEMPLATES.helloworld-ts.name",
3 | "desc": "TEMPLATES.helloworld-ts.desc",
4 | "banner": "template-banner.png"
5 | }
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "lib": [ "dom", "es5", "es2015.promise" ],
5 | "target": "es5",
6 | "allowJs": true,
7 | "experimentalDecorators": true,
8 | "skipLibCheck": true
9 | },
10 | "exclude": [
11 | "node_modules",
12 | "library",
13 | "local",
14 | "temp",
15 | "build",
16 | "settings"
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------