Пример #1
0
    def createStaticColorOverlays(self):
        img = self._imagemanager.load(
            "data/tilesets/toilett_singecolor_overlay.png")
        overlay = fife.OverlayColors(img)
        overlay.changeColor(fife.Color(255, 255, 255),
                            fife.Color(0, 0, 255, 128))
        for n in (1, 5, 9):
            instance = self._actorlayer.getInstance("toilett%s" % n)
            instance.addStaticColorOverlay(0, overlay)

        img = self._imagemanager.load(
            "data/tilesets/toilett_multicolor_overlay.png")
        overlay = fife.OverlayColors(img)
        overlay.changeColor(fife.Color(255, 0, 0), fife.Color(255, 0, 0, 80))
        overlay.changeColor(fife.Color(0, 255, 0), fife.Color(0, 255, 0, 80))
        overlay.changeColor(fife.Color(0, 0, 255), fife.Color(0, 0, 255, 80))
        for n in (2, 6, 10):
            instance = self._actorlayer.getInstance("toilett%s" % n)
            instance.addStaticColorOverlay(0, overlay)

        overlay.changeColor(fife.Color(255, 0, 0), fife.Color(255, 0, 0, 200))
        overlay.changeColor(fife.Color(0, 255, 0), fife.Color(0, 255, 0, 200))
        overlay.changeColor(fife.Color(0, 0, 255), fife.Color(0, 0, 255, 200))
        for n in (3, 7, 11):
            instance = self._actorlayer.getInstance("toilett%s" % n)
            instance.addStaticColorOverlay(0, overlay)
Пример #2
0
	def add_overlay(self, overlay_name, z_order):
		"""Creates color overlay recoloring the area defined in *overlay_set*

		and adds it to fife instance. Note that a color overlay on *z_order*
		can only be visible if an animation overlay with that specific order
		exists as well. For order 0, `convertToOverlays()` makes sure they do.
		"""
		if not self.fife_instance.isAnimationOverlay(self.identifier):
			# parameter False: do not convert color overlays attached to base
			self.fife_instance.convertToOverlays(self.identifier, False)

		all_action_sets = ActionSetLoader.get_sets()
		try:
			overlay_set = all_action_sets[self.action_set][overlay_name]
		except KeyError:
			self.log.warning(
				'Could not find overlay action set `%s` defined for object '
				'`%s` with id `%s`. Not adding overlay for this action.',
				overlay_name, self.instance, self.identifier)
			return

		self.current_overlays[z_order] = overlay_set
		for rotation, frames in overlay_set.iteritems():
			ov_anim = fife.Animation.createAnimation()
			for frame_img, frame_data in frames.iteritems():
				try:
					frame_length = frame_data[0]
				except TypeError:
					# not using atlases
					frame_length = frame_data
				pic = horizons.globals.fife.imagemanager.load(frame_img)
				frame_milliseconds = int(frame_length * 1000)
				ov_anim.addFrame(pic, frame_milliseconds)
			overlay = fife.OverlayColors(ov_anim)
			self.fife_instance.addColorOverlay(self.identifier, rotation, z_order, overlay)
Пример #3
0
	def createColorOverlay(self):
		# create color overlay for skels
		delay = 200
		for rotation in range(0, 360, 45):
			anim = self._animationmanager.create("skel_stand_overlay" + str(rotation))
			for frame in range(4):
				resource = ("overlay_stand_"
				            + str(rotation) + "_"
				            + str(frame) + ".png")
				anim.addFrame(self._imagemanager.get(resource), delay)

			overlay = fife.OverlayColors(anim)
			# skel 1
			overlay.changeColor(fife.Color(255,0,0), fife.Color(255,0,0,80))
			overlay.changeColor(fife.Color(0,0,255), fife.Color(0,0,255,80))
			self._skel1.addColorOverlay("stand", rotation, overlay)
			# skel 2
			overlay.changeColor(fife.Color(255,0,0), fife.Color(0,255,0,128))
			overlay.changeColor(fife.Color(0,0,255), fife.Color(0,255,0,128))
			self._skel2.addColorOverlay("stand", rotation, overlay)