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


Python Sprite.owner方法代码示例

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


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

示例1: context_menu

# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import owner [as 别名]
    def context_menu(self, obj, action="show"):
        self.wipe_context_menu()
        category = "context"
        texture = image.load(RES_PATH + 'ui/upgrade.png')
        texture = center_image(texture)
        offset =  (
            0.0 - texture.width // 2,
            obj.height // 2 + texture.height // 2
        )
        b_sprite = Sprite(
                texture,
                x=obj.x + offset[0],
                y=obj.y + offset[1],
                batch=self.w.batches["buttons"],
                group=self.w.ui_group
        )

        b_sprite.offset = offset
        b_sprite.active = True
        b_sprite.b_price = obj.price // 2
        if b_sprite.b_price > self.w.game.gold:
            b_sprite.opacity = 80
        b_sprite.b_type = "upgrade"
        b_sprite.category = category
        b_sprite.owner = obj
        self.context_sprites.append(b_sprite)

        size = 10
        offset = (
            0.0 - texture.width // 2 + 1,
            obj.height // 2 + texture.height // 2 + (size * 1.5) - 1
        )
        x = obj.x + offset[0]
        y = obj.y + offset[1]
        label = text.Label(
            str(obj.price // 2), font_name='Visitor TT1 BRK',
            font_size=size,
            x=x,
            y=y,
            batch=self.w.batches["buttons"],
            anchor_x="center", anchor_y="center",
            color=(32, 32, 32, 196)
        )
        label.offset = offset
        label.owner = obj
        label.b_type = "upgrade"
        label.category = category
        label.shadow = True
        self.context_sprites.append(label)

        offset = (
            0.0 - texture.width // 2,
            obj.height // 2 + texture.height // 2 + (size * 1.5)
        )
        x = obj.x + offset[0]
        y = obj.y + offset[1]
        label = text.Label(
            str(obj.price // 2), font_name='Visitor TT1 BRK',
            font_size=size,
            x=x,
            y=y,
            batch=self.w.batches["buttons"],
            anchor_x="center", anchor_y="center",
            color=(130, 255, 130, 255)
        )
        label.offset = offset
        label.owner = obj
        label.b_type = "upgrade"
        label.category = category
        label.shadow = False
        if obj.price // 2 > self.w.game.gold:
            label.color = (255, 140, 140, 225)
        self.context_sprites.append(label)

        texture = image.load(RES_PATH + 'ui/sell.png')
        texture = center_image(texture)
        offset =  (
            texture.width // 2,
            obj.height // 2 + texture.height // 2
        )
        b_sprite = Sprite(
                texture,
                x=obj.x + offset[0],
                y=obj.y + offset[1],
                batch=self.w.batches["buttons"],
                group=self.w.ui_group
        )
        b_sprite.offset = offset
        b_sprite.active = True
        b_sprite.b_price = obj.price
        b_sprite.b_type = "sell"
        b_sprite.category = category
        b_sprite.owner = obj
        self.context_sprites.append(b_sprite)
开发者ID:NiclasEriksen,项目名称:py-towerwars,代码行数:96,代码来源:ui.py

示例2: showContextMenu

# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import owner [as 别名]
    def showContextMenu(self, obj, action="show"):
        self.wipeContextMenu()
        category = "context"
        texture = self.w.textures['upgrade']
        offset =  (
            -texture.width,
            0
        )
        b_sprite = Sprite(
                texture,
                x=obj.x + offset[0],
                y=obj.y + offset[1],
                batch=self.w.batches["buttons"],
                group=self.w.ui_group
        )

        b_sprite.offset = offset
        b_sprite.active = True
        b_sprite.b_price = obj.price // 2
        if b_sprite.b_price > self.w.game.gold:
            b_sprite.opacity = 80
        b_sprite.b_type = "upgrade"
        b_sprite.category = category
        b_sprite.owner = obj
        self.context_sprites.append(b_sprite)

        size = 10
        offset = (
            -texture.width - 1,
            texture.width // 2 - 1
        )
        x = obj.x + offset[0]
        y = obj.y + offset[1]
        label = text.Label(
            str(obj.price // 2), font_name='Visitor TT1 BRK',
            font_size=size,
            x=x,
            y=y,
            batch=self.w.batches["buttons"],
            anchor_x="center", anchor_y="center",
            color=(32, 32, 32, 196)
        )
        label.offset = offset
        label.owner = obj
        label.b_type = "upgrade"
        label.category = category
        label.shadow = True
        self.context_sprites.append(label)

        size = 10
        offset = (
            0,
            obj.image.height
        )
        x = obj.x + offset[0]
        y = obj.y + offset[1]
        label = text.Label(
            str(int(obj.dmg)), font_name='Visitor TT1 BRK',
            font_size=size,
            x=x,
            y=y,
            batch=self.w.batches["buttons"],
            anchor_x="center", anchor_y="center",
            color=(32, 32, 32, 255)
        )
        label.offset = offset
        label.owner = obj
        label.b_type = "towerinfo"
        label.category = category
        label.shadow = False
        self.context_sprites.append(label)

        offset = (
            -texture.width,
            texture.width // 2
        )
        x = obj.x + offset[0]
        y = obj.y + offset[1]
        label = text.Label(
            str(obj.price // 2), font_name='Visitor TT1 BRK',
            font_size=size,
            x=x,
            y=y,
            batch=self.w.batches["buttons"],
            anchor_x="center", anchor_y="center",
            color=(130, 255, 130, 255)
        )
        label.offset = offset
        label.owner = obj
        label.b_type = "upgrade"
        label.category = category
        label.shadow = False
        if obj.price // 2 > self.w.game.gold:
            label.color = (255, 140, 140, 225)
        self.context_sprites.append(label)

        texture = self.w.textures["sell"]
        offset = (
            texture.width,
            0
#.........这里部分代码省略.........
开发者ID:NiclasEriksen,项目名称:py-towerwars,代码行数:103,代码来源:ui.py


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