本文整理汇总了Python中pyglet.sprite.Sprite.opacity方法的典型用法代码示例。如果您正苦于以下问题:Python Sprite.opacity方法的具体用法?Python Sprite.opacity怎么用?Python Sprite.opacity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyglet.sprite.Sprite
的用法示例。
在下文中一共展示了Sprite.opacity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addEntry
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import opacity [as 别名]
def addEntry(self, title="No title", action=None, top=False):
h = self.but_h
w = self.but_w
x = self.w.width / 2
y = (
self.w.height / 2 - (h * len(self.entries)) +
self.spacing
)
if title == "New Game":
btn_texture = self.w.textures["button_green_jagged"]
elif title == "Exit":
btn_texture = self.w.textures["button_red"]
else:
btn_texture = self.w.textures["button_brown"]
b_sprite = Sprite(
btn_texture,
x=x,
y=y,
batch=self.w.batches["mm_buttons"],
group=self.w.ui_group,
)
b_sprite.opacity = 150
# b_sprite.width, b_sprite.height = 3, 1
b_sprite.rectangle = create_rectangle(x, y, w, h)
b_sprite.action = action
b_sprite.label = text.Label(
title, font_name='Visitor TT1 BRK',
font_size=self.font_size,
color=self.font_clr,
x=x, y=y,
batch=self.w.batches["mm_labels"],
anchor_x="center", anchor_y="center"
)
b_sprite.label.oldfontsize = b_sprite.label.font_size
b_sprite.orig_size = self.but_w, self.but_h
b_sprite.bw, b_sprite.bh = b_sprite.orig_size
if top:
self.entries.insert(0, b_sprite)
self.updateOffset()
else:
self.entries.append(b_sprite)
self.updateOffset()
示例2: context_menu
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import opacity [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)
示例3: showContextMenu
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import opacity [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
#.........这里部分代码省略.........