本文整理汇总了Python中pyglet.sprite.Sprite.rectangle方法的典型用法代码示例。如果您正苦于以下问题:Python Sprite.rectangle方法的具体用法?Python Sprite.rectangle怎么用?Python Sprite.rectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyglet.sprite.Sprite
的用法示例。
在下文中一共展示了Sprite.rectangle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_entry
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import rectangle [as 别名]
def add_entry(self, title="No title", action=None):
b_sprite = Sprite(
self.w.textures["wall_stone"],
x=self.w.width / 2,
y=self.w.height / 2 - (32 * len(self.entries)),
batch=self.w.batches["mm_buttons"],
group=self.w.ui_group
)
# b_sprite.width, b_sprite.height = 3, 1
x, y = b_sprite.x, b_sprite.y
b_sprite.rectangle = create_rectangle(x, y, 128, 32)
b_sprite.action = action
b_sprite.label = text.Label(
title, font_name='Soft Elegance',
font_size=14,
x=x, y=y,
anchor_x="center", anchor_y="center"
)
self.entries.append(b_sprite)
示例2: addEntry
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import rectangle [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()