我目前正在摆弄 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() )
我想要做的是在第一个标签下方显示第二个标签,并将第一个标签的三分之一向右移动。
有谁知道我如何获得第一个标签的宽度?
编辑:这是开发人员关于为什么没有明确访问权限的答案的问题。
请您参考如下方法:
