[英]How to find layer width/height with cocos python
我目前正在擺弄 python 和 cocos2D
我想制作一個帶有縮進空間的簡單顯示,就像這樣
import cocos
from cocos.director import director
class MyLayer(cocos.layer.Layer):
def __init__(self):
#Setting the coordinate for the base layer
self.x = 200
self.y = 100
#A first layer of text
x_basic_text = 0
y_basic_text = 0
self.basic_text = cocos.text.Label("Unindented text", x=x_basic_text, y=y_basic_text )
#A second layer of text
y_indent_text = -20 #So that it doesn't squeeze with the basic text layer
x_indent_text = self.basic_text.width/3 #which doesn't work since layers have no width attribute
self.indent_text = cocos.text.Label("Indented text", x=x_indent_text, y=y_indent_text )
director.init(resizable=True)
director.run( MyLayer() )
我想要做的是在第一個標簽下方顯示第二個標簽,並將第一個標簽的三分之一向右移動。
有誰知道我如何獲得第一個標簽的寬度?
編輯:這是開發人員關於為什么沒有明確訪問權限的答案的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.