本文整理汇总了C++中spActor::attachTo方法的典型用法代码示例。如果您正苦于以下问题:C++ spActor::attachTo方法的具体用法?C++ spActor::attachTo怎么用?C++ spActor::attachTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spActor
的用法示例。
在下文中一共展示了spActor::attachTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void DeveloperMenu::init(const Vector2 &size, const char *text, spActor data, const Color &color)
{
const float BORDER = 3;
float offset = 24;
setSize(size);
setWidth(data->getWidth() + BORDER * 2);
setHeight(size.y + offset);
//setSize(data->getSize() + Point(0, offset));
spColorRectSprite top = new ColorRectSprite();
top->setWidth(getWidth());
top->setSize(size);
_topDrag.init(top.get());
_topDrag.setDragClient(this);
addChild(top);
top->setColor(windowColor);
top->setSize(Vector2(getWidth(), offset));
top->setPriority(100);
spColorRectSprite body = new ColorRectSprite();
body->setColor(color);
addChild(body);
body->setSize(Vector2(getWidth() - BORDER * 2, getHeight()));
body->setX(BORDER);
body->setY((float)offset);
_body = body;
TextStyle style;
style.font = _resSystem->getResFont("system")->getFont();
style.vAlign = TextStyle::VALIGN_TOP;
spButton close = initActor(new Button,
arg_y = offset/2,
arg_x = offset/2,
arg_anchor = Vector2(0.5f, 0.5f),
arg_resAnim = _resSystem->getResAnim("remove"),
arg_attachTo = top);
close->addEventListener(TouchEvent::CLICK, CLOSURE(this, &DeveloperMenu::close));
spTextField title = initActor(new TextField,
arg_style = style,
arg_hAlign = TextStyle::HALIGN_MIDDLE,
arg_vAlign = TextStyle::VALIGN_MIDDLE,
arg_text = text,
arg_width = top->getWidth(),
arg_height = top->getHeight(),
arg_input = false,
arg_attachTo = top);
//title->setSize(close->getTextRect().size);
title->addEventListener(TouchEvent::CLICK, CLOSURE(this, &DeveloperMenu::close));
data->attachTo(body);
}