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


Python DirectFrame.set_transparency方法代码示例

本文整理汇总了Python中direct.gui.DirectFrame.DirectFrame.set_transparency方法的典型用法代码示例。如果您正苦于以下问题:Python DirectFrame.set_transparency方法的具体用法?Python DirectFrame.set_transparency怎么用?Python DirectFrame.set_transparency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在direct.gui.DirectFrame.DirectFrame的用法示例。


在下文中一共展示了DirectFrame.set_transparency方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Menu

# 需要导入模块: from direct.gui.DirectFrame import DirectFrame [as 别名]
# 或者: from direct.gui.DirectFrame.DirectFrame import set_transparency [as 别名]
class Menu(object):
    def __init__(self,main): 
        self.main=main

        wx = base.win.get_x_size()
        wy = base.win.get_y_size()
        kx = 1920
        ky = 1080
        self.myFrame = DirectFrame(frameColor=(1,1,1,1),
            frameSize=(0, kx,0, ky))

        menu_tex = loader.loadTexture("res/menu.png")
        menu_tex.set_minfilter(SamplerState.FT_nearest)
        menu_tex.set_magfilter(SamplerState.FT_linear)
        self.myFrame["frameTexture"] = menu_tex
        self.myFrame.reparentTo(base.pixel2d)
        self.myFrame.set_pos( (wx-kx) / 2, 0, -(wy+ky) / 2)
        self.myFrame.set_transparency(True)

        self.startButton = DirectButton(
                    text = "",  
                    text_scale=1.0,
                    text_fg=(0.2,0.2,0.2,1),
                    frameTexture="res/start_game.png",
                    frameColor=(1,1,1,1),
                    frameSize=(-64, 64, -20, 20),
                    command=self.main.startGame,
                    relief=DGG.FLAT,
                    rolloverSound=None,
                    clickSound=None,
                    parent=self.myFrame,
                    scale=2.0,
                    pos=(wx/2 + 160, 0, wy/2 + 50)
                    )
        self.startButton.setTransparency(1)

        self.exitButton = DirectButton(
                    text = ("Exit Game"),  
                    pos=(0,0,-.8),
                    text_scale=.1,
                    frameColor=(0,0,0,0),
                    relief=1,
                    frameVisibleScale=(2,3),
                    command=exit,
                    rolloverSound=None,
                    clickSound=None,
                    parent=self.myFrame,
                    )
        self.exitButton.setTransparency(1)
        
        self.resumeButton = DirectButton(
                    text = ("Resume"),  
                    pos=(.0,0,.3),
                    text_scale=.1,
                    frameColor=(0,0,0,0),
                    relief=1,
                    frameVisibleScale=(2,3),
                    command=self.main.resumeGame,
                    rolloverSound=None,
                    clickSound=None,
                    parent=self.myFrame,
                    )
        
        self.resumeButton.setTransparency(1)
        self.resumeButton.hide()
        
        self.selectFrame= DirectFrame( frameColor=(1,1,1,1) , frameSize=(-64, 64, -20, 20) , frameTexture="res/select.png")
        self.selectFrame.setTransparency(1)
        self.selectFrame.reparentTo(self.startButton)
        self.entries = [self.exitButton,self.startButton,self.resumeButton]
        self.activeEntry = 1


    
    
    def clearKeys(self):
        base.ignore("arrow_up")
        base.ignore("arrow_down")
        base.ignore("arrow_left")
        base.ignore("arrow_right")
        base.ignore("escape")
        base.ignore("enter")
    
    def execSelection(self):
        self.entries[self.activeEntry]["command"]()
      
        
    def selectDown(self):
        if self.activeEntry == 0:
            self.activeEntry = len(self.entries)-1
        else:
            self.activeEntry -=1
        
        if self.entries[self.activeEntry].isHidden():
            self.selectDown()
            return   
        self.selectFrame.reparentTo(self.entries[self.activeEntry])
        
    def selectUp(self):

#.........这里部分代码省略.........
开发者ID:eswartz,项目名称:RenderPipeline-Samples,代码行数:103,代码来源:Menu.py


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