每当我运行此代码时,它都会在screen.blit
之前停止,同时仍在循环,并一遍又一遍地打印'debug3'
。
它甚至都没有意识到未定义屏幕,我的意图是让它运行screen.blit
。
...
playermove = 5
walkL=pygame.image.load("files/sprites/walkL.png")
walkR=pygame.image.load("files/sprites/walkR.png")
currentSprite = walkL
#single sprite size (width, height)
h=128
w=57
numImages = 4
#counter
cImage=0
class Player:
def animation(self):
global cImage,numImages,currentSprite,playerRect,w,h
if (cImage>=numImages-1):
cImage=0
else:
cImage+=1
print('debug3')
screen.blit(currentSprite,playerRect, (cImage*w,0,w,h))
while True:
player.animation()
答案 0 :(得分:2)
如果您查看else语句,则需要缩进'print'调用以与'cImage + = 1'对齐。
----来自代码示例的片段----
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_ENCODING , "gzip");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept-Encoding: gzip, deflate, br',
));
$html = curl_exec($ch);
curl_close($ch);
-------结束代码段-----------------