本文整理汇总了Python中pyglet.sprite.Sprite.offset方法的典型用法代码示例。如果您正苦于以下问题:Python Sprite.offset方法的具体用法?Python Sprite.offset怎么用?Python Sprite.offset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyglet.sprite.Sprite
的用法示例。
在下文中一共展示了Sprite.offset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: context_menu
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import offset [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)
示例2: showContextMenu
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import offset [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
#.........这里部分代码省略.........