ding_shi_qiao

游戏目标

制作定时桥,当人物未在规定时间内过桥将会失败。

大体需要以下几个步骤:

  1. 制作地形,建造一座桥 Bridge
  2. 制作按键 ButtonBridge
  3. 制作计时器 TimerDisplay

PS:这是少儿编程

Game Goal

Make a timed bridge: if the character fails to cross the bridge within the set time, the game fails.

Roughly the following steps are needed:

  1. Create the terrain and build a bridge — Bridge
  2. Make the button — BridgeButton
  3. Make the timer — TimerDisplay

PS: this is kids’ programming

Roblox Studio

Roblox 中国官网

https://roblox.cn/

解决 Roblox Studio 中国版一直正在登录的问题

安装好 Roblox Studio 后第一次使用可以打开软件界面,从第二次打开软件开始,就一直卡在正在登录的界面。我也不知道具体什么原因,大胆猜测是因为 Roblox 在国内和鹅厂有一些 PY 交易,所以问题出在鹅厂身上😏。image-20211108193743354看这快捷方式的后缀,本来陌生而又高大上的东西瞬间就亲切了许多

因为考虑到是鹅厂的问题,我就翻墙去了国际版官网 https://roblox.com 下载了国际版的 Roblox Studio ,并且在全局代理的模式下尝试登录国际版的账号。好家伙,点击登录一点反应也没有!

最后,女朋友帮 她自己找到了解决方案。

进入下面的文件夹:

C:\Users\ {你的用户名} \AppData\Local\Roblox\Versions-qq\version-{乱七八糟}

打开 RobloxStudioLauncherBeta.exe

如果成功,将RobloxStudioLauncherBeta.exe发送到桌面快捷方式。

如果过几天发现快捷方式也不好用,可以通过写 bat 文件的形式创建快捷方式。

新建一个 Roblox Studio.txt 文件,在文件中写入如下内容。

1
start C:\Users\{你的用户名}\AppData\Local\Roblox\Versions-qq\version-{乱七八糟的字符串}\RobloxStudioLauncherBeta.exe

最后,重命名文件为 Roblox Studio.bat ,双击这个文件,就可以打开 Roblox Studio 了。

Roblox Studio

Roblox China Official Website

https://roblox.cn/

Fixing the China Version of Roblox Studio Being Stuck on “Logging In”

After installing Roblox Studio, the first use works and opens the software interface, but from the second launch on, it’s stuck on the “logging in” screen. I don’t know the exact reason; my bold guess is that Roblox has some shady deals with Tencent in China, so the problem lies with Tencent 😏.image-20211108193743354Look at the suffix of this shortcut — something that was unfamiliar and high-end instantly feels much friendlier

Since I figured it was Tencent’s problem, I used a VPN to visit the international official site https://roblox.com, downloaded the international version of Roblox Studio, and tried logging in with an international account in global proxy mode. Wow — clicking Login had no response at all!

In the end, my girlfriend helped me — well, she herself found the solution.

Go into the following folder:

C:\Users\ {你的用户名} \AppData\Local\Roblox\Versions-qq\version-{乱七八糟}

Open RobloxStudioLauncherBeta.exe

If it works, send RobloxStudioLauncherBeta.exe to the desktop as a shortcut.

If the shortcut stops working after a few days, you can create a shortcut by writing a bat file.

Create a new Roblox Studio.txt file and write the following into it:

1
start C:\Users\{你的用户名}\AppData\Local\Roblox\Versions-qq\version-{乱七八糟的字符串}\RobloxStudioLauncherBeta.exe

Finally, rename the file to Roblox Studio.bat; double-click this file and you can open Roblox Studio.

界面搭建

打开软件,点击新增,使用 Baseplate 创建你的游戏。

image-20211108200242352

在地形编辑器中点击 生成,勾选 平原丘陵山脉,点击生成按钮。

image-20211108200634524

创建好的地形看不见人物的出现的地点,我们通过依次点击 模型=> 重生点,可以看见场景中显示了玩家出现的位置。

image-20211108200904583

通过地形编辑器,侵蚀,把地面挖个坑出来。

image-20211108201650749

再通过地形编辑器的填充操作,把坑里放上水。

image-20211108201910699

接下来要插入三个 Part 组件,分别用来充当桥,倒计时显示器,和倒计时按钮。

右键 => 插入部件。

image-20211108202220817

可以看到场景中多了个小方块并且项目管理器中多了个 Part。

image-20211108202329538

使用缩放工具可以调整部件的大小。

image-20211108202438547

我们再插入两个部件作为桥和倒计时显示器。把地形做成如下形式,并且做好重命名工作。

image-20211108203437374

接下来对各个部件的属性进行设置。

首先,对三个组件都进行 Anchor(锚固),可以通过点击菜单栏中编辑选项卡中的 锚固,也可以再属性列表中勾选 Anchored。

image-20211108203901907

桥的属性:

  1. Transparency(透明度)设置为 0.8

  2. 取消选中 CanCollide

  3. 修改颜色

  4. 修改材质

在过桥时,玩家需要看到在桥消失之前还剩几秒。显示图像或文本的一种方法是将一个称作 SurfaceGUI 的对象添加到部件中。

首先将 TimerDisplay 部件加入 SurfaceGUI。

image-20211108204422255

在刚添加的 GUI 中,添加 TextLabel。

image-20211108204546104

现在,你可能甚至无法看到 TextLabel,它非常小,并且可能位于计时器显示的错误一侧。为了让玩家可以更好地查看计时器,应该将更改与 SurfaceGUI 相连的一侧并使 SurfaceGUI 变得更大。

我这里需要把 SurfaceGUI 的 Face 属性改成 Back,修改后可以看到组件的左上角有一块变了颜色。放大查看那里就是 TextLabel 显示的文字。

image-20211108205130879

image-20211108205209494

接下来我们需要调整 TextLabel 的大小和位置等属性。

我这里设置 TextLabel 的 Size 属性与 SurfaceGUI 的大小相同,并勾选 TextScaled 属性。

image-20211108205753474

image-20211108205900650

Building the Interface

Open the software, click New, and use Baseplate to create your game.

image-20211108200242352

In the terrain editor, click Generate, check Plains, Hills, and Mountains, then click the Generate button.

image-20211108200634524

On the created terrain you can’t see where the character spawns; click through Model => SpawnLocation and you can see where players will appear in the scene.

image-20211108200904583

Use the terrain editor’s Erode tool to dig a hole in the ground.

image-20211108201650749

Then use the terrain editor’s fill operation to put water into the hole.

image-20211108201910699

Next, insert three Part components to serve as the bridge, the countdown display, and the countdown button.

Right-click => Insert Part.

image-20211108202220817

You can see a small block appears in the scene and a Part appears in the Explorer.

image-20211108202329538

Use the Scale tool to adjust the size of the part.

image-20211108202438547

Insert two more parts to serve as the bridge and the countdown display. Shape the terrain as shown below, and do the renaming properly.

image-20211108203437374

Next, configure the properties of each part.

First, Anchor all three components. You can click Anchor in the Edit tab of the menu bar, or check Anchored in the properties list.

image-20211108203901907

Bridge properties:

  1. Set Transparency to 0.8

  2. Uncheck CanCollide

  3. Change the color

  4. Change the material

While crossing the bridge, players need to see how many seconds are left before the bridge disappears. One way to display images or text is to add an object called SurfaceGUI to the part.

First, add a SurfaceGUI to the TimerDisplay part.

image-20211108204422255

In the GUI just added, add a TextLabel.

image-20211108204546104

Now you may not even be able to see the TextLabel — it’s very small and may be on the wrong side of the timer display. To let players see the timer better, you should change the side the SurfaceGUI is attached to and make the SurfaceGUI bigger.

Here I need to change the SurfaceGUI’s Face property to Back. After the change, you can see a block in the top-left corner of the component has changed color. Zoom in — that’s where the TextLabel text is displayed.

image-20211108205130879

image-20211108205209494

Next, we need to adjust the TextLabel’s size, position, and other properties.

Here I set the TextLabel’s Size property to the same size as the SurfaceGUI and checked the TextScaled property.

image-20211108205753474

image-20211108205900650

脚本编写

我们在 Bridge 组件下创建 timedBridge 脚本文件,写入如下内容。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
local bridge = game.Workspace.Bridge
local button = game.Workspace.BridgeButton

local timerpart = game.Workspace.TimerDisplay
local timertext = timerpart.SurfaceGui.TextLabel
timertext.Text = ""

local time5 = 5
local time_active = false

local function startTimer()
time_active = true
bridge.Transparency = 0
bridge.CanCollide = true
for count = time5,0,-1 do
timertext.Text = count
wait(1)
end
bridge.Transparency = 0.8
bridge.CanCollide = false
time_active = false
timertext.Text = ""
end

local function buttonPressed(otherPart)
local char = otherPart.Parent
print(char)
local humanoid = char:FindFirstChildWhichIsA("Humanoid")
print("111")
print(humanoid)
if humanoid and time_active == false then
startTimer()
print("1111")
end
end

button.Touched:Connect(buttonPressed)

少儿编程的逻辑,就不解释了

just-and-forceful

Writing the Script

Create a timedBridge script under the Bridge component and write the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
local bridge = game.Workspace.Bridge
local button = game.Workspace.BridgeButton

local timerpart = game.Workspace.TimerDisplay
local timertext = timerpart.SurfaceGui.TextLabel
timertext.Text = ""

local time5 = 5
local time_active = false

local function startTimer()
time_active = true
bridge.Transparency = 0
bridge.CanCollide = true
for count = time5,0,-1 do
timertext.Text = count
wait(1)
end
bridge.Transparency = 0.8
bridge.CanCollide = false
time_active = false
timertext.Text = ""
end

local function buttonPressed(otherPart)
local char = otherPart.Parent
print(char)
local humanoid = char:FindFirstChildWhichIsA("Humanoid")
print("111")
print(humanoid)
if humanoid and time_active == false then
startTimer()
print("1111")
end
end

button.Touched:Connect(buttonPressed)

The logic is for kids’ programming, so I won’t explain it.

just-and-forceful