【中英双语】桌球小游戏教程—更新第2节

Cocos Creator入门实战:桌球小游戏(1)

How to make a simple snooker game with CocosCreator (1)

桌球小游戏是 BigBear (引擎组大佬)设计、撰写的中英双语的 Cocos Creator 入门教程,面向 Cocos Creator 初学者,但不论你当前技术如何,相信你在 BigBear 老师的带领下定会有所收获。

Shawn 昨天推送了完整的中文版本,为了降低大家的学习难度,我将《Cocos Creator入门实战:桌球小游戏》一文拆分成若干篇中英双语的教程,我们一起学习游戏、学习英语(看我公众号的名字就知道Shawn的英语有多low)!

开始之前 Before Start

在开始桌球小游戏之前,我们需要对creator有一定了解以及熟悉,对js语法有一定的了解。在开始同样还是希望大家能够仔细的阅读一遍官方文档,以便理解。

Before start things with Cocos Creator to make our game, you should have a familiarity understanding with Cocos Creator.if there are any questions in the production, pls check those Cocos’s offical document:

所涉及到的知识点参考:

  • Physics
  • UI System
  • Listen to and launch events
  • Actions and Action Lists
  • Prefab
  • Atlas Asset

ps:本项目所使用的Cocos Creator版本为 v2.0.10

ps: this tutorial is based with Cocos Creator v2.0.10

开启物理系统 (Use physics system)

为了尽量达到真实的效果,我们对于桌球的运动均采用物理模拟来实现。
在Cocos Creator中物理系统是默认关闭的,我们可以通过下面的代码来开启物理系统:

We use physical simulation to acheieve the movement of the balls, so the balls can move as much as reality movement.Physics system is closed by default in Cocos Creator, we can open it with those code:

let physicsManager = cc.director.getPhysicsManager();
physicsManager.enabled = true;

同时我们也可以通过设置debugDrawFlags来开启一些调试信息的显示,方便我们开发预览:

also we can set physics system to a debug mode that we can see more debug info in preview:

cc.director.getPhysicsManager().debugDrawFlags = cc.PhysicsManager.DrawBits.e_aabbBit |
    cc.PhysicsManager.DrawBits.e_pairBit |
    cc.PhysicsManager.DrawBits.e_centerOfMassBit |
    cc.PhysicsManager.DrawBits.e_jointBit |
    cc.PhysicsManager.DrawBits.e_shapeBit;

完整链接 :
https://mp.weixin.qq.com/s/aY5Krqua1m43_N7b80gxIA

原文连载进行中,请关注微信公众号「奎特尔星球」,一起编程、英语、娱乐、学习、交友!

【中英双语】桌球小游戏教程(2)

在Canvas下面创建一个子节点作为我们的桌面节点。
Create a sprite node named ‘table’, its parent is ‘Canvas’ node. This node is our billiard table.

给它添加一个cc.Sprite组件并且给予它显示的spriteFrame
Set its spriteframe proerty used the spriteframe asset named ‘bg’

添加RighdBody组件
Now we implement its physics features

由于桌面是静止不动的,因此我们将Type设置为Static。
Since the table is motionless, we set the Type property with Static.

去掉AwakeOnLoad,因为我们并不需要它处于唤醒状态。
Unselect the AwakeOnLoad property, because we do not want it awakened.

#完整地址
https://mp.weixin.qq.com/s/TMaUETF_j1e3vy0E5lRdeA

#音频地址
我在喜马拉雅测试朗读了一下,有谁可以拯救我,敢比我更读的歪:joy:
https://m.ximalaya.com/share/sound/203050970?uid=62705031&shrdv=ffffffff-ae64-0479-0000-0000003652ee&shrh5=android&shrid=16c647f8e1b1622e&shrdh=1&shrpid=16c647f8e1b9a5d