搅拌器的Python错误
问题描述:
我得到这个错误:搅拌器的Python错误
Traceback (most recent call last):
File "movement", line 1, in (module) NameError: name 'GameLogic' is not defined
import GameLogic
cont = GameLogic.getCurrentController()
fwd = cont.sensors['forword']
bck = cont.sensors['backword']
lft = cont.sensors['left']
rit = cont .sensors['right']
move = cont.actuators['move']
speed = [0, 0, 0]
rot = [0, 0, 0]
if fwd.positive:
# speed[0] 0 mean the movement will be according tot he x axis
# speed[1] 1 mean according to the y axis and 2 for z axis
speed[0] = 0.7
elif bck.positive:
speed[0] = -0.7
if lft.positive:
rot[0] = 0.1
elif rit.positive:
rot[0] = -0.1
move.uselocalDloc = true
move.uselocDrot = false
move.dloc = speed
move.drot = rot
cont.activate(move)
答
GameLogic是C扩展模块。它只能在游戏引擎中运行,当从Python游戏逻辑控制器执行时,会有很多示例文件在线显示如何完成此操作。
那么你的问题是什么? – orftz 2011-05-29 21:43:02
我得到这个错误:回溯(最近一次调用最后一次): 文件“移动”,行1,在(模块)NameError:名称'GameLogic'未定义 – shaimaa 2011-05-29 23:27:09