def get_frame_images(self): filename = destandardize_path(os.path.split(self.folder)[1]) path = os.path.join(destandardize_path(self.folder),filename+"*.*") if self.last_frame_info == path: return self.frames frames = Opioid2D.ResourceManager.get_pattern(path) self.last_frame_info = path return frames
def get_frame_images(self): filename = destandardize_path(os.path.split(self.folder)[1]) path = os.path.join(destandardize_path(self.folder), filename + "*.*") if self.last_frame_info == path: return self.frames frames = Opioid2D.ResourceManager.get_pattern(path) self.last_frame_info = path return frames
def get_sound( filename, volume = 1.0, tag=""): """get_sound( filename, volume = 1.0, tag="")->pygame.mixer.Sound object Create a sound object with a 'play' method. If filename evaluates to False, a dummy sound object will be created that has a 'play' method that does nothing. filename: path to the sound file. mp3, wav, or midi volume: you can pass a float from 0 to 1 for the sound volume. A unique sound will be created with that volume. You can still set the volume of a sound, but that will change all sounds with this tag/volume combination. tag: if you want to create different sound objects with the same sound file, you can give them different tags """ if not filename: return NoneSound() index = filename+"_"+tag+"_"+str(volume) sound = SoundDict.get(index, None) if sound is None: try: sound = SoundDict[index] = load_sound(filename) except: sound = SoundDict[index] = load_sound( destandardize_path(filename)) sound.set_volume(volume) return sound
def set_image(self, image): try: OpioidSprite.set_image(self, image) except: image = destandardize_path(image) OpioidSprite.set_image(self, image) if isinstance(image, basestring): self._image_file = image
def set_image(self, image): try: OpioidSprite.set_image( self, image) except: image = destandardize_path(image) OpioidSprite.set_image( self, image) if isinstance(image, basestring): self._image_file = image
def set_font_file(self, font_file=None, font_size=None): if font_file is None: font_file = self._font_file else: self._font_file = font_file if font_size is None: font_size = self._font_size else: self._font_size = font_size font_info = (destandardize_path(font_file), self._font_size) try: self.font = self.font_cache[font_info] except KeyError: try: self.font = font.Font(*font_info) except: self.font = self.__class__.font self._font_file = self.__class__._font_file else: self.font_cache[font_info] = self.font self.set_text()
def get_sound(filename, volume=1.0, tag=""): """get_sound( filename, volume = 1.0, tag="")->pygame.mixer.Sound object Create a sound object with a 'play' method. If filename evaluates to False, a dummy sound object will be created that has a 'play' method that does nothing. filename: path to the sound file. mp3, wav, or midi volume: you can pass a float from 0 to 1 for the sound volume. A unique sound will be created with that volume. You can still set the volume of a sound, but that will change all sounds with this tag/volume combination. tag: if you want to create different sound objects with the same sound file, you can give them different tags """ if not filename: return NoneSound() index = filename + "_" + tag + "_" + str(volume) sound = SoundDict.get(index, None) if sound is None: try: sound = SoundDict[index] = load_sound(filename) except: sound = SoundDict[index] = load_sound(destandardize_path(filename)) sound.set_volume(volume) return sound