本文整理汇总了Python中pygame.error方法的典型用法代码示例。如果您正苦于以下问题:Python pygame.error方法的具体用法?Python pygame.error怎么用?Python pygame.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygame
的用法示例。
在下文中一共展示了pygame.error方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_sound
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import error [as 别名]
def get_sound(*names, **kwds):
if sound_cache is None:
return dummy_sound
path = _resource_path("sounds", names, **kwds)
sound = sound_cache.get(path)
if not sound:
try:
from pygame.mixer import Sound
except ImportError, e:
no_sound(e)
return dummy_sound
try:
sound = Sound(path)
except pygame.error, e:
missing_sound(e, path)
return dummy_sound
示例2: __play
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import error [as 别名]
def __play(self, file, start_millis):
# Stop anything previous
self.stop()
# Set states
self.__paused = False
self.__done = False
# Get the file
try:
pygame.mixer.music.load(file)
except pygame.error:
self.__done = True
raise AudioException("Error occurred loading '{}': {}".format(file, pygame.get_error()))
# Play the file and tick until play completed
pygame.mixer.music.play(start=start_millis / 1000)
while pygame.mixer.music.get_busy():
sleep(DMXMINWAIT)
# Let everyone know play is done
self.__done = True
示例3: load_image
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import error [as 别名]
def load_image(name, colorkey=None, scale=WIDTH_UNIT/13):
fullname = os.path.join(data_dir, 'images', name)
try:
image = pygame.image.load(fullname)
except pygame.error:
print('Cannot load image:', fullname)
raise SystemExit(str(geterror()))
image = image.convert()
if colorkey is not None:
if colorkey is -1:
colorkey = image.get_at((0, 0))
image.set_colorkey(colorkey, RLEACCEL)
image = pygame.transform.scale(image, tuple(round(scale*x) for x in image.get_rect().size))
return image, image.get_rect()
示例4: load_sound
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import error [as 别名]
def load_sound(name):
class NoneSound:
def play(self): pass
if not pygame.mixer or not pygame.mixer.get_init():
return NoneSound()
fullname = os.path.join(data_dir, 'sound', name)
try:
sound = pygame.mixer.Sound(fullname)
except pygame.error:
print('Cannot load sound: %s' % fullname)
raise SystemExit(str(geterror()))
return sound
示例5: load_image
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import error [as 别名]
def load_image(filename, colorkey=None):
filename = os.path.join("data", filename)
try:
image = pygame.image.load(filename)
except pygame.error, message:
print "Cannot load image:", filename
raise SystemExit, message
示例6: load_image
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import error [as 别名]
def load_image(dir, file, colorkey=None):
file = os.path.join(dir, file)
try:
image = pygame.image.load(file)
except pygame.error, message:
print "Cannot load image:", file
raise SystemExit, message
示例7: load_image
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import error [as 别名]
def load_image(filename, colorkey=None):
filename = os.path.join("mapchip", filename)
try:
image = pygame.image.load(filename)
except pygame.error, message:
print "Cannot load image:", filename
raise SystemExit, message