当前位置: 首页>>代码示例>>Python>>正文


Python pygame.error方法代码示例

本文整理汇总了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 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:18,代码来源:resource.py

示例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 
开发者ID:MattIPv4,项目名称:PyDMXControl,代码行数:24,代码来源:_Player.py

示例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() 
开发者ID:HuangJunye,项目名称:QPong,代码行数:16,代码来源:resources.py

示例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 
开发者ID:HuangJunye,项目名称:QPong,代码行数:14,代码来源:resources.py

示例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 
开发者ID:aidiary,项目名称:pygame,代码行数:9,代码来源:pyrpg11.py

示例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 
开发者ID:aidiary,项目名称:pygame,代码行数:9,代码来源:pyrpg22.py

示例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 
开发者ID:aidiary,项目名称:pygame,代码行数:9,代码来源:pymap03.py


注:本文中的pygame.error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。