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


Python text.Label类代码示例

本文整理汇总了Python中cocos.text.Label的典型用法代码示例。如果您正苦于以下问题:Python Label类的具体用法?Python Label怎么用?Python Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: on_key_press

 def on_key_press(self, k, m):
     if k == key.BACKSPACE:
         self.name.element.text = self.name.element.text[0:-1]
         return True
     elif k == key.ENTER:
         if len(self.name.element.text) <= 2:
             w, h = director.get_window_size()
             label_s = Label(
                 'Name too short! Choose at least 3 characters',
                 font_name=_font_,
                 font_size=20,
                 anchor_y='top',
                 anchor_x='center')
             label_s.position = (w/2., 700.)
             self.add(label_s)
         elif len(self.name.element.text) >= 15:
             w, h = director.get_window_size()
             label_l = Label(
                 'Name too long! Not more than 15 characters allowed',
                 font_name=_font_,
                 font_size=20,
                 anchor_y='top',
                 anchor_x='center')
             label_l.position = (w/2., 750.)
             self.add(label_l)
         else:
             new_score(self.name.element.text, self.wave)
             director.pop()
         return True
     elif k == key.ESCAPE:
         director.pop()
         return True
     return False
开发者ID:faide,项目名称:pyfense,代码行数:33,代码来源:highscore.py

示例2: __init__

 def __init__(self, wave):
     super().__init__()
     w, h = director.get_window_size()
     self.wave = wave
     self.font_title = {
         'font_name': _font_,
         'font_size': 72,
         'anchor_y': 'top',
         'anchor_x': 'center'
     }
     title = Label('GameOver', **self.font_title)
     title.position = (w/2., h)
     self.add(title, z=1)
     self.font_label = {
         'font_name': _font_,
         'font_size': 40,
         'anchor_y': 'top',
         'anchor_x': 'center'
     }
     label = Label('Enter your name:', **self.font_label)
     label.position = (w/2., 600.)
     self.add(label)
     self.name = Label('', color=(192, 192, 192, 255), **self.font_label)
     self.name.position = (w/2., 530.)
     self.add(self.name)
开发者ID:faide,项目名称:pyfense,代码行数:25,代码来源:highscore.py

示例3: __init__

    def __init__(self):
        super(Credits, self).__init__()

        opts = {
            'font_name': 'against myself',
            'font_size': 70,
            'anchor_x': 'center',
            'anchor_y': 'center',
        }

        label = Label('Credits', color=(0x00, 0x00, 0x00, 0xff), **opts)
        label.position = 400, 500
        self.add(label, z=1)

        label = Label('Credits', color=(0xff, 0xff, 0xff, 0xff), **opts)
        label.position = 400, 503
        self.add(label, z=2)

        shadow = DEVELOPERS.replace("white", "black")
        developers = HTMLLabel(shadow, width=760, height=300, multiline=True)
        developers.position = 20, 298
        self.add(developers, z=1)

        developers = HTMLLabel(DEVELOPERS, width=760, height=300, multiline=True)
        developers.position = 20, 300
        self.add(developers, z=2)
开发者ID:andrewsmedina,项目名称:jailbreakerz,代码行数:26,代码来源:credits.py

示例4: GenericControllerBehavior

class GenericControllerBehavior(CtrlBehavior):
	def __init__(self):
		super(GenericControllerBehavior, self).__init__()
		global behavior_name
		self.display_name = behavior_name
		self.label = Label("", font_size=9, font_name="Cabin Regular", anchor_x="center", anchor_y="top", color=(255, 255, 255, 255))
		self.init_attribute('control_distance', 'ControlDistance', (0,1000), 'generic_controller_default_control_distance', 10)
		
	def associate(self, behavior):
		super(GenericControllerBehavior, self).associate(behavior)
		self.set_control_menu_mode()
	
	def update(self):
		super(GenericControllerBehavior, self).update()
		if self.controlled_attribute:
			distance = self.object.translation.distance(self.association.object.translation)
			distance_ratio = max(0, min(1.3, distance * 1.0 / self.attributes['control_distance'].value) - 0.3)
			value = self.controlled_attribute.range[0] + (distance_ratio * (self.controlled_attribute.range[1] - self.controlled_attribute.range[0]))
			self.controlled_attribute.set(value)
	
	def draw_foreground(self):
		super(GenericControllerBehavior, self).draw_foreground()
		if self.controlled_attribute:
			coords = self.object.screen_coords()
			self.label.position = coords.x, coords.y - 10
			self.label.element.text = "%s: %s" % (self.controlled_attribute.display_name, self.controlled_attribute.to_string())
			self.label.element.color = (255, 255, 255, int(self.object.alpha() * 255))
			self.label.draw()
开发者ID:ice3,项目名称:Glovebox,代码行数:28,代码来源:generic_controller.py

示例5: create_page_select

    def create_page_select(self):
        '''创建关卡选择的页面选择器'''
        levels = self.get_all_level()
        count_pre_pages = 10
        pages = len(levels) // count_pre_pages + 1
        self.page_count = pages
        last_page = Label('上一页')
        next_page = Label('下一页')
        y = 100
        lx = 320 - 54
        nx = 320 + 10
        for i in range(pages):
            # 从中间开始放页码
            if i < pages / 2:
                x = 320 - (pages / 2 - i) * 20
                lx = 320 - pages / 2 * 20 - 64
            else:
                x = 320 + (i - pages / 2) * 20
                nx = 320 + pages / 2 * 20 + 10
            label = Label(str(i + 1), position=(x, y))
            last_page.position = (lx, y)
            next_page.position = (nx, y)
            r = Rect(label.x, label.y, 10, 16)
            self.page_select.append([r, label])
            self.add(label)

        lr = Rect(last_page.x, last_page.y, 50, 20)
        nr = Rect(next_page.x, next_page.y, 50, 20)
        self.page_select.append([lr, last_page])
        self.page_select.append([nr, next_page])
        self.add(last_page)
        self.add(next_page)
开发者ID:ElfenSterben,项目名称:dzk_loadfile,代码行数:32,代码来源:editor.py

示例6: __init__

    def __init__(self):
        super(Layer2, self).__init__(231, 76, 60, 1000)

        # Same Label code as before but this time with different text
        text = Label("This is the second scene")
        text.position = director._window_virtual_width / 2, director._window_virtual_height / 2
        self.add(text)
开发者ID:MagicPwn,项目名称:cocos2d-python-tutorials,代码行数:7,代码来源:scenes.py

示例7: IntroLayer

class IntroLayer(Layer):
    is_event_handler = True
    def __init__(self):
        super(IntroLayer, self).__init__()
        self.img = pyglet.resource.image('background.png')
        self.intro_text = Label('Made by some Asshole:', font_size=24,
                           font_name='Times New Roman',
                           color=(255,255,255,255),
                           anchor_x='left',
                           anchor_y='bottom')
        self.intro_text.position = (0, 0)
        self.add(self.intro_text)
    def draw(self):
        glPushMatrix()
        self.transform()
        self.intro_text.draw()
        self.img.blit(0, 0)
        glPopMatrix()
    def start_game(self):
        scene = Scene()
        scene.add(MultiplexLayer(
                         MainMenu(),
                         OptionsMenu(),
                         HiScoresLayer(),
                         ), z=1)
        scene.add(BackgroundLayer(), z=0)
        director.push(ShuffleTransition(scene, 1.5))
    def on_key_press(self, k, m):
        if k in (pyglet.window.key.ENTER, pyglet.window.key.ESCAPE, pyglet.window.key.SPACE):
            self.start_game()
            return True
    def on_mouse_press(self, x, y, b, m):
        self.start_game()
        return True
开发者ID:mcgillij,项目名称:pygauntlet,代码行数:34,代码来源:gamelayers.py

示例8: TestLayer

class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super( TestLayer, self ).__init__()

        x,y = director.get_window_size()
        self.color = [127, 127, 127, 255]

        self.label = Label(time.ctime(), (x/2, y/2))
        self.label.do( Rotate( 360, 10 ) )
        self.add( self.label  )

        self.schedule_interval(self.update_time, .1)

    def update_time(self, dt):
        self.label.element.text = time.ctime()
        self.color[:3] = [self._change_color(self.color[i]) for i in range(3)]
        self.label.element.color = self.color

    def _change_color(self, old_color):
        new_color = old_color + random.randint(-10, 10)
        if new_color > 255:
            new_color = 255
        if new_color < 0:
            new_color = 0
        return new_color
开发者ID:adamwiggins,项目名称:cocos2d,代码行数:25,代码来源:test_label_changing.py

示例9: reload

	def reload(self, model, hero_name):
		w, h = director.get_window_size()
		sc = 1920/w
		self.model = model
		self.name = hero_name
		if self.name == 'wizard':
			self.hero = self.model.heroes[self.name]
			self.sprite = Sprite(Images.hero_icons[self.name], (1600//sc, 900//sc), scale = 1/sc)
			self.sprite_black = Sprite(Images.hero_icons_black[self.name], (1600//sc, 900//sc), scale = 1/sc)
			self.label = Label('%d' %self.hero.stats.health, font_name='Times New Roman', font_size=20//sc, anchor_x='center', anchor_y='center', color = (255, 0, 0, 255) )
			self.label.position = 1600//sc, 870//sc
		if self.name == 'priest':
			self.hero = self.model.heroes[self.name]
			self.sprite = Sprite(Images.hero_icons[self.name], (1720//sc, 900//sc), scale = 1/sc)
			self.sprite_black = Sprite(Images.hero_icons_black[self.name], (1720//sc, 900//sc), scale = 1/sc)
			self.label = Label('%d' %self.hero.stats.health, font_name='Times New Roman', font_size=20//sc, anchor_x='center', anchor_y='center', color = (255, 0, 0, 255) )
			self.label.position = 1720//sc, 870//sc
		if self.name == 'warrior':
			self.hero = self.model.heroes[self.name]
			self.sprite = Sprite(Images.hero_icons[self.name], (1600//sc, 780//sc), scale = 1/sc)
			self.sprite_black = Sprite(Images.hero_icons_black[self.name], (1600//sc, 780//sc), scale = 1/sc)
			self.label = Label('%d' %self.hero.stats.health, font_name='Times New Roman', font_size=20//sc, anchor_x='center', anchor_y='center', color = (255, 0, 0, 255) )
			self.label.position = 1600//sc, 750//sc
		if self.name == 'rogue':
			self.hero = self.model.heroes[self.name]
			self.sprite = Sprite(Images.hero_icons[self.name], (1720//sc, 780//sc), scale = 1/sc)
			self.sprite_black = Sprite(Images.hero_icons_black[self.name], (1720//sc, 780//sc), scale = 1/sc)
			self.label = Label('%d' %self.hero.stats.health, font_name='Times New Roman', font_size=20//sc, anchor_x='center', anchor_y='center', color = (255, 0, 0, 255) )
			self.label.position = 1720//sc, 750//sc
开发者ID:XRater,项目名称:Dungeon-defenders,代码行数:29,代码来源:gamemodel.py

示例10: __init__

	def __init__(self):
		super().__init__()

		width, height = director.get_window_size()
		paused = Label(_("PAUSE"), font_name="Ubuntu", font_size=64, bold=True,
		               color=Options.FONT_COLOR, anchor_x="center", anchor_y="center")
		paused.position = width // 2, height // 2
		paused.do(Repeat(FadeOut(0.3) + FadeIn(0.3)))  # blink
		self.add(paused)
开发者ID:brunonova,项目名称:collision,代码行数:9,代码来源:pause.py

示例11: __init__

	def __init__(self):
		super().__init__(*Options.BACKGROUND_COLOR)

		version = Label(font_name=Options.FONT_NAME, font_size=16,
		                color=Options.FONT_COLOR_NOT_SELECTED,
		                anchor_x="right", anchor_y="bottom")
		version.position = director.get_window_size()[0] - 5, 5
		version.element.text = _("Version: {}").format(Options.VERSION)
		self.add(version)
开发者ID:brunonova,项目名称:collision,代码行数:9,代码来源:menu.py

示例12: __init__

 def __init__(self):
     super(Start, self).__init__()
     label = Label('打砖块', font_size=42)
     label2 = Label('press any key to start')
     label.position = (230, 300)
     label2.position = (240, 150)
     self.count = 0
     self.add(label)
     self.add(label2)
     self.schedule(self.update)
开发者ID:ElfenSterben,项目名称:dzk_randomlevel,代码行数:10,代码来源:main.py

示例13: __init__

	def __init__( self, win):
		super(GameOver,self).__init__( 32,32,32,64)

		w,h = director.get_window_size()
		if (win == False):
			label = Label('Game Over', font_name='Edit Undo Line BRK', font_size=54, anchor_y='center', anchor_x='center' )
		if (win == True):
			label = Label('You Won', font_name='Edit Undo Line BRK', font_size=54, anchor_y='center', anchor_x='center' )
		label.position =  ( w/2.0, h/2.0 )
		self.add( label )
开发者ID:PFML239,项目名称:Dungeon-defenders,代码行数:10,代码来源:game_view.py

示例14: __init__

    def __init__(self):
        super(ReaderScene, self).__init__()
        self.text = ""
        if(self.text_file):
            self.text = data.load(self.text_file).read()

        self.font_item['text'] = self.text
        label = Label(**self.font_item )
        label.content_width = 300
        self.label = label
        self.add(label,z=9999)
开发者ID:HieuLsw,项目名称:blobjob,代码行数:11,代码来源:reader_scene.py

示例15: __init__

 def __init__(self):
     width, height = director.get_window_size()
     super(HiScoresLayer, self).__init__(32, 32, 32, 16, width=width, height=height-86)
     self.font_title = {}
     self.font_title['font_name'] = 'Times New Roman'
     self.font_title['font_size'] = 72
     self.font_title['color'] = (204, 164, 164, 255)
     self.font_title['anchor_x'] = 'center'
     self.font_title['anchor_y'] = 'top'
     title = Label('Scores!', **self.font_title)
     title.position = (width/2.0, height)
     self.add(title, z=1)
     self.table = None
开发者ID:mcgillij,项目名称:pygauntlet,代码行数:13,代码来源:gamelayers.py


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