当前位置: 首页>>代码示例>>Python>>正文


Python Label.anchor方法代码示例

本文整理汇总了Python中cocos.text.Label.anchor方法的典型用法代码示例。如果您正苦于以下问题:Python Label.anchor方法的具体用法?Python Label.anchor怎么用?Python Label.anchor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cocos.text.Label的用法示例。


在下文中一共展示了Label.anchor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: updateWithSize

# 需要导入模块: from cocos.text import Label [as 别名]
# 或者: from cocos.text.Label import anchor [as 别名]
 def updateWithSize(self, ws, so, zm):
     self._stageOrigin[0] = int(self._stageOrigin[0])
     self._stageOrigin[1] = int(self._stageOrigin[1])
     
     if self._winSize == ws and self._stageOrigin == so and self._zoom == zm:
         return
     
     self._winSize = ws
     self._stageOrigin = so
     self._zoom = zm
     
     # TODO:@twenty0ne
     # CCScale9Sprite.preferedSize
     # Resize backrounds
     self._bgHorizontal.scale_x = self._winSize[0]/self._bgHorizontal.width
     self._bgHorizontal.scale_y = self._kCCBRulerWidth/self._bgHorizontal.height
     
     self._bgVertical.scale_x = self._kCCBRulerWidth/self._bgVertical.width
     self._bgVertical.scale_y = self._winSize[1]/self._bgVertical.height
     
     # Add marks and numbers
     for obj in self._marksVertical.get_children():
         self._marksVertical.remove(obj)
     for obj in self._marksHorizontal.get_children():
         self._marksHorizontal.remove(obj)
         
     # Vertical marks
     y = int(so[1]) - (int(so[1])/10)*10
     while y < ws[1]:
         yDist = abs(y - int(self._stageOrigin[1]))
         
         mark = None
         addLabel = False
         if yDist == 0:
             mark = Sprite("images/ruler-mark-origin.png")
             addLabel = True
         elif yDist%50 == 0:
             mark = Sprite("images/ruler-mark-major.png")
             addLabel = True
         else:
             mark = Sprite("images/ruler-mark-minor.png")
         mark.image_anchor = 0,0.5
         mark.position = 0,y
         self._marksVertical.add(mark)
         
         if addLabel:
             displayDist = yDist / self._zoom
             strDist = str(displayDist)
             strLen = len(strDist)
             for i in range(0, strLen):
                 lbl = Label(strDist[i], color=(0,0,0,255), font_size=8)
                 lbl.anchor = 0,0
                 lbl.position = 2,(y+1+10*(strLen-i-1))
                 self._marksVertical.add(lbl)
         
         y = y + 10
         
     # Horizontal marks
     x = int(so[0]) - (int(so[0])/10)*10
     while x < ws[0]:
         xDist = abs(x - int(self._stageOrigin[0]))
         
         mark = None
         addLabel = False
         if xDist == 0:
             mark = Sprite("images/ruler-mark-origin.png")
             addLabel = True
         elif xDist%50 == 0:
             mark = Sprite("images/ruler-mark-major.png")
             addLabel = True
         else:
             mark = Sprite("images/ruler-mark-minor.png")
         mark.image_anchor = 0,0.5
         mark.position = x,0
         mark.rotation = -90
         self._marksHorizontal.add(mark)
         
         if addLabel:
             displayDist = xDist / self._zoom
             lbl = Label(str(displayDist), color=(0,0,0,255), font_size=8)
             lbl.anchor = 0,0
             lbl.position = x+1,1
             self._marksHorizontal.add(lbl)
         
         x = x + 10
开发者ID:twenty0ne,项目名称:CocosBuilder-wxPython,代码行数:87,代码来源:RulersLayer.py


注:本文中的cocos.text.Label.anchor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。