本文整理汇总了Python中pyglet.sprite.Sprite.category方法的典型用法代码示例。如果您正苦于以下问题:Python Sprite.category方法的具体用法?Python Sprite.category怎么用?Python Sprite.category使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyglet.sprite.Sprite
的用法示例。
在下文中一共展示了Sprite.category方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_button
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import category [as 别名]
def add_button(self, b_type):
if b_type == "1":
x = 20
y = 20
category = "tower"
texture = self.w.textures["tower_wood"]
active = True
b_price = self.w.game.available_towers[b_type]
elif b_type == "2":
x = 20
y = 20 + self.b_size
category = "tower"
texture = self.w.textures["tower_poison"]
active = True
b_price = self.w.game.available_towers[b_type]
elif b_type == "3":
x = 20
y = 20 + self.b_size * 2
category = "tower"
texture = self.w.textures["tower_splash"]
active = True
b_price = self.w.game.available_towers[b_type]
elif b_type == "4":
x = 20
y = 20 + self.b_size * 3
category = "tower"
texture = self.w.textures["tower_chain"]
active = True
b_price = self.w.game.available_towers[b_type]
elif b_type == "gold_icon":
texture = image.load(RES_PATH + 'ui/gold.png')
texture = center_image(texture)
x = texture.width + 2
y = self.w.height - (texture.height + 2)
category = "ui"
active = False
b_price = False
b_type = "icon"
else:
return False
b_sprite = Sprite(
texture,
x=x, y=y,
batch=self.w.batches["buttons"],
group=self.w.ui_group
)
b_sprite.category = category
b_sprite.b_type = b_type
b_sprite.active = active
b_sprite.b_price = b_price
self.sprites.append(b_sprite)
示例2: context_menu
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import category [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 category [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
#.........这里部分代码省略.........