pygame-1.9.1release/docs/tut/chimp/ChimpLineByLine.html
1)pygame中有些模块有时是无效的,当无效时,其值为None,可以通过如下方法判断
if not pygame.font: print 'Warning, fonts disabled'
2)Surface.set_colorkey
设置Surface的透明色。当把 这个Surface blit到令一个Surface时候,和这个透明色颜色相同的像素会变成透明。具体使用方法参照API
3)如果是找不到音乐文件是,可以返回一个NoneSound,保证程序正常执行。
def load_sound(name):
class NoneSound:
def play(self): pass
if not pygame.mixer:
return NoneSound()
fullname = os.path.join('data', name)
try:
sound = pygame.mixer.Sound(fullname)
except pygame.error, message:
print 'Cannot load sound:', wav
raise SystemExit, message
return sound
4)可以用矩形自带的方法执行move,判断是否在矩形内等