下面是我在pygame库中使用pygame库编写的一个简单platformer游戏的代码片段:
def animate(self):
if self.jumping and not self.onplatform:
if self.small:
self.image = self.jumpingimage_small
else:
self.image = self.jumpingimage
elif (self.left or self.right) and not self.small:
self.counter +=1
if self.counter == 1:
self.image = self.walkingimage[1]
elif self.counter == 5:
self.image = self.walkingimage[2]
elif self.counter == 9:
self.image = self.walkingimage[3]
elif self.counter == 13:
self.counter = 0
elif not (self.left or self.right):
if not self.small:
self.image = self.normalimage
else:
self.image = self.smallimage
if self.facing == "left":
self.image = pygame.transform.flip(self.image,True,False)
self.flipped = True
它应该做的是动画我的精灵一个球员对象。它有一个用来跳跃的精灵,一个用来静止的精灵,还有三个行走的框架自走图像[1] 分别是[2]和[3]。在
最后我调用pygame方法pygame.transform.flip()当玩家面朝左时(它们本来都是向右的)翻转所有精灵
所以我指定了一个图像(Pygame Surface?)到a自我形象属性从未更改的基础精灵列表中移除(全部面向右侧)。在
对于只有一个动画帧为跳跃和正常(静止)的精灵来说,这一切都很好,但是当我尝试移动时,它在标准图像和翻转图像之间快速地来回变化。这不是bliting的情况,因为我是在指定并有选择地翻转图像之后才这样做的。在
我把它贴在这里是因为我一辈子都找不到错误。我是不是用错了flip()方法?在
目前没有回答
相关问题 更多 >
编程相关推荐