當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。