Blender 3D:零基础到专业级-单元3:拓展视野
Completion requirements
Mouse Pointer
::鼠标指针
Making a simple mouse pointer in the game engine. This takes up a lot of resources but it is very simple.
::在游戏引擎中制作一个简单的鼠标指针. 这需要大量的资源,但它非常简单.
A little Python is involved but it is very easy to use and is only 2 lines of code.
::虽然它包含一些Python, 但使用起来很简单,
-
Open up blender and split the screen in two.
::打开混合器,把屏幕分成两部分. -
Make the right screen a text editor and add a new text file with
ALT+N
. Type in the following code.
import Rasterizer as r r.showMouse(1)
::将右边的屏幕变成一个文本编辑器,并用ALT+N添加一个新的文本文件. 输入以下代码. 导入Rasterizer作为r r.showMouse(1) -
Set
TX: showpointer
in the middle of the Text panel menu bar.
::在文本面板菜单中间设置TX:showpointer. -
Select an object that will always be available - preferably a camera.
::选择一个永远可用的物体 - - 最好是相机. -
Go to the logic tab, add a
"Property" sensor
, a
"Python" controller
, an
"AND" controller
and a
"Property" actuator
.
::添加一个"属性"传感器,一个"Python"控制器,一个"AND"控制器和一个"属性"执行器. -
Activate the
True Level Triggering
(the
“‘
button), set
Prop: switch
and
Value: 0
. Connect the property sensor to the python and AND controllers by dragging lines between the bullets.
::激活真实级别触发 (按),设置 Prop: 开关和 Value: 0. 通过在子弹之间拖动线条将属性传感器连接到 Python 和 AND 控制器. -
For the python controller set
Script: showpointer
. Note: If the value keeps being reverted to blank after setting it, the name you entered is not a legal script name; chances are you did not set the name of your script correctly. Look for the selection menu beginning with "TX:" and make sure it says
TX:showpointer
.
::对于python控制器设置的Script:showpointer. 注意:如果设置后值一直被恢复为空白,那么您输入的名称不是合法的脚本名称;您可能没有正确设置脚本名称. 寻找以"TX:"开始的选择菜单,并确保它说TX:showpointer. -
Now connect the AND controller to the property actuator. Set
Prop: switch
and
Value: 1
.
::现在将AND控制器连接到属性执行器.设置Prop:开关和Value: 1. -
Select
Actor
and click on
Add Property
make it a
Int
type and set
Name:switch
.
::选择"Actor"并点击"添加属性",使其成为Int类型,并设置"name:switch".
Now press
P
to start the game and now you`ll see your mouse pointer.
::现在按P开始游戏, 现在你会看到你的鼠标指针.
Last modified: Monday, 17 March 2025, 2:28 PM