本文整理汇总了Python中Base.tuple_add方法的典型用法代码示例。如果您正苦于以下问题:Python Base.tuple_add方法的具体用法?Python Base.tuple_add怎么用?Python Base.tuple_add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base
的用法示例。
在下文中一共展示了Base.tuple_add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OnDrag
# 需要导入模块: import Base [as 别名]
# 或者: from Base import tuple_add [as 别名]
def OnDrag(self):
"""When the draggable is latched to the cursor, this is carried out.
By default it moves the draggable along with the cursor. TODO: Correct
the unintentional displacement of the draggable if the mouse was moved
quickly right before dragging the box"""
translation = Base.tuple_add(pygame.mouse.get_pos(), self.previous_pos, '-')
self.Translate(translation, None, True)
self.previous_pos = pygame.mouse.get_pos()
示例2: _blitToolTip
# 需要导入模块: import Base [as 别名]
# 或者: from Base import tuple_add [as 别名]
def _blitToolTip(self):
"""Check if a tooltip is expected and draw it"""
if not pygame.font or self.ToolItem == None:
self.ToolTipBox = pygame.Surface((0,0)).convert()
return True
elif self.ToolItem.DrawToolTip:
fontsize = 20
self.surf.blit(self.ToolTipBox, Base.tuple_add(self.ToolItem.Sprite.rect.topleft,(10,fontsize+5), '-'))
return False
示例3: RenderToolTip
# 需要导入模块: import Base [as 别名]
# 或者: from Base import tuple_add [as 别名]
def RenderToolTip(self):
"""Prepares a tooltip for the UI class to draw if needed. TODO: Needs to
be refactored"""
if self.ToolTip == None:
return False
fontsize = 20
font = pygame.font.Font(None, fontsize)
text = font.render(self.ToolTip, 1, (250, 250, 250))
hoverBox = pygame.Surface(Base.tuple_add(text.get_rect()[2:],(fontsize,6))).convert()
hoverBox.fill((0,100,200))
textpos = text.get_rect(centerx=hoverBox.get_width()/2, centery=hoverBox.get_height()/2)
hoverBox.blit(text, textpos)
return hoverBox
示例4: Translate
# 需要导入模块: import Base [as 别名]
# 或者: from Base import tuple_add [as 别名]
def Translate(self, reposition, translim = None, clip = False, wrap = False):
"""This accumulates residual float movement and uses it to move the sprite over calls"""
if translim == None:
limx, limy = Base.tuple_add(self.surf.get_size(), self.rect.size, '-')
else:
limx, limy = translim
oldpos = self.rect.topleft
#Accumulate residue from new repositioning
Base.tuple_add(self.translate_residue, [r-int(r) for r in reposition])
#Trim reposition of float portion
reposition = [int(x) for x in reposition]
#Update reposition to take whole residues
reposition = Base.tuple_add(reposition, [int(r) for r in self.translate_residue])
#Update residue to remove whole portion used in reposition
self.translate_residue = [r-int(r) for r in self.translate_residue]
want_to = Base.tuple_add(oldpos, reposition)
self.rect.topleft = Base.tuple_lim(Base.tuple_add(oldpos, reposition), limx, limy, wrap)
if not clip:
self.rect.topleft = want_to
if self.rect.topleft == want_to:
return True
else:
return wrap or False