-2
我們正在使用面頰編程軟件 它使用Python,但我們是在它很新,我們得到這個錯誤:Python的全局變量縮進
Indentation Error: unindent does not match any outer indentation level
在標線
。任何想法爲什麼?
import viz
import math
import viztask
count = 0
boolTime = False
viz.setMultiSample(4)
viz.fov(20)
viz.go()
viz.phys.enable()
viz.phys.setGravity([0, 0, 0])
viz.window.setFullscreen()
viz.setOption('viz.model.apply_collada_scale',1)
ball = viz.add('ball.dae')
ball.setPosition([-0.1,1.5,4])
#ball.setScale([0.75,0.75,0.75])
ball.collideSphere()
viz.setOption('viz.model.apply_collada_scale',1)
path = viz.addChild('path.dae')
path.setPosition([-1,1.0,4])
path.collideMesh()
#collision
path.enable(viz.COLLIDE_NOTIFY)
def onCollide(e):
global count
count = count+1
print(count)
viz.callback(viz.COLLIDE_BEGIN_EVENT, onCollide)
#mouse
viz.mouse.setOverride(viz.ON)
link = None
def grabBall():
global link
link = viz.grab(viz.Mouse, ball)
boolTime = True # ERROR HERE
def releaseBall():
global link
link.remove()
link = None
def TestReactionTime():
while boolTime:
#Wait for next frame to be drawn to screen
d = yield viztask.waitDraw()
#Save display time
displayTime = d.time
#Wait for keyboard reaction
d = yield viztask.waitMouseUp(viz.MOUSEBUTTON_LEFT)
#Calculate reaction time
reactionTime = d.time - displayTime
print(reactionTime)
vizact.onmousedown(viz.MOUSEBUTTON_LEFT, TestReactionTime)
vizact.onmousedown(viz.MOUSEBUTTON_LEFT,grabBall)
vizact.onmouseup(viz.MOUSEBUTTON_LEFT,releaseBall)
請不要*後處理有語法錯誤的代碼。 – 2014-09-27 16:16:32
你最有可能混合標籤和空格。確保您的編輯器爲每個縮進級別插入4個空格,並且沒有製表符。 – 2014-09-27 16:18:06
另外,如果要保留更改,boolTime需要一個'global',就像該函數中的鏈接變量一樣。 – user3557327 2014-09-27 16:26:06