コード例 #1
0
    def __init__(self, name, position, width, height):
        """
        Constructor
        """

        # position = (410, 280)
        # width = 400
        # height = 600

        PlatformerMenu.__init__(self, name, position, width, height)

        # music
        meterPos = (20, 40)
        meterWidth = 320
        meterHeight = 25

        self._meterBack = Box(meterPos, meterWidth, meterHeight, Color(0, 0, 0))
        self.AddChild(self._meterBack)
        self._meter = Meter(
            meterPos, meterWidth, meterHeight, Color(255, 255, 255), pygame.mixer.music.get_volume, lambda: 1.0
        )
        self.AddChild(self._meter)

        fontPath = os.path.join(Constants.GameConstants.BASE_PATH, "content/fonts/upheavtt.ttf")

        self._musicText = Text((140, 0), fontPath, 32, "MUSIC", Color(0, 255, 0))
        self.AddChild(self._musicText)

        self._musicMinus = PlatformerFunctionMenuButton(
            "Music Minus", self.__decrementMusic__, (-5, 38), fontPath, 32, "-", Color(0, 255, 0), None
        )
        self.AddChild(self._musicMinus)

        self._musicPlus = PlatformerFunctionMenuButton(
            "Music Plus", self.__incrementMusic__, (350, 35), fontPath, 32, "+", Color(0, 255, 0), None
        )
        self.AddChild(self._musicPlus)

        # sound effects
        meterPos = (20, 110)
        meterWidth = 320
        meterHeight = 25

        self._meterBack = Box(meterPos, meterWidth, meterHeight, Color(0, 0, 0))
        self.AddChild(self._meterBack)
        self._meter = Meter(
            meterPos,
            meterWidth,
            meterHeight,
            Color(255, 255, 255),
            lambda: Constants.GameConstants.SOUND_VOLUME,
            lambda: 1.0,
        )
        self.AddChild(self._meter)

        self._soundText = Text((140, 70), fontPath, 32, "SOUND", Color(0, 255, 0))
        self.AddChild(self._soundText)

        self._soundMinus = PlatformerFunctionMenuButton(
            "Sound Minus", self.__decrementSound__, (-5, 108), fontPath, 32, "-", Color(0, 255, 0), None
        )
        self.AddChild(self._soundMinus)

        self._soundPlus = PlatformerFunctionMenuButton(
            "Sound Plus", self.__incrementSound__, (350, 105), fontPath, 32, "+", Color(0, 255, 0), None
        )
        self.AddChild(self._soundPlus)

        # navigation
        self._musicMinus.RightNeighborName = self._musicPlus.Name
        self._musicMinus.BelowNeighborName = self._soundMinus.Name

        self._musicPlus.LeftNeighborName = self._musicMinus.Name
        self._musicPlus.BelowNeighborName = self._soundPlus.Name

        self._soundMinus.RightNeighborName = self._soundPlus.Name
        self._soundMinus.AboveNeighborName = self._musicMinus.Name

        self._soundPlus.LeftNeighborName = self._soundMinus.Name
        self._soundPlus.AboveNeighborName = self._musicPlus.Name
コード例 #2
0
ファイル: PlatformerPauseMenu.py プロジェクト: cadryden/cad-e
 def __init__(self, name, position=None, width=None, height=None):
     
     PlatformerMenu.__init__(self, name, position, width, height)
     
     bgWidget = UI.Box.Box(position, width, height, pygame.Color(0, 0, 0, 0))
     self.AddChild(bgWidget)