本文整理汇总了C++中Viewport::add_child方法的典型用法代码示例。如果您正苦于以下问题:C++ Viewport::add_child方法的具体用法?C++ Viewport::add_child怎么用?C++ Viewport::add_child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Viewport
的用法示例。
在下文中一共展示了Viewport::add_child方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _screen_pick_pressed
void ColorPicker::_screen_pick_pressed() {
Viewport *r = get_tree()->get_root();
if (!screen) {
screen = memnew(Control);
r->add_child(screen);
screen->set_as_toplevel(true);
screen->set_area_as_parent_rect();
screen->connect("gui_input", this, "_screen_input");
}
screen->raise();
screen->show_modal();
r->queue_screen_capture();
}
示例2: _screen_pick_pressed
void ColorPicker::_screen_pick_pressed() {
Viewport *r = get_tree()->get_root();
if (!screen) {
screen = memnew(Control);
r->add_child(screen);
screen->set_as_toplevel(true);
screen->set_anchors_and_margins_preset(Control::PRESET_WIDE);
screen->set_default_cursor_shape(CURSOR_POINTING_HAND);
screen->connect("gui_input", this, "_screen_input");
}
screen->raise();
screen->show_modal();
}
示例3: init
virtual void init() {
SceneMainLoop::init();
#if 0
Viewport *vp = memnew( Viewport );
vp->set_world( Ref<World>( memnew( World )));
get_root()->add_child(vp);
vp->set_rect(Rect2(0,0,256,256));
vp->set_as_render_target(true);
vp->set_render_target_update_mode(Viewport::RENDER_TARGET_UPDATE_ALWAYS);
Camera *camera = memnew( Camera );
vp->add_child(camera);
camera->make_current();
TestCube *testcube = memnew( TestCube );
vp->add_child(testcube);
testcube->set_transform(Transform( Matrix3().rotated(Vector3(0,1,0),Math_PI*0.25), Vector3(0,0,-8)));
Sprite *sp = memnew( Sprite );
sp->set_texture( vp->get_render_target_texture() );
// sp->set_texture( ResourceLoader::load("res://ball.png") );
sp->set_pos(Point2(300,300));
get_root()->add_child(sp);
return;
#endif
Panel * frame = memnew( Panel );
frame->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END );
frame->set_anchor( MARGIN_BOTTOM, Control::ANCHOR_END );
frame->set_end( Point2(0,0) );
get_root()->add_child( frame );
Label *label = memnew( Label );
label->set_pos( Point2( 80,90 ) );
label->set_size( Point2( 170,80 ) );
label->set_align( Label::ALIGN_FILL );
//label->set_text("There");
label->set_text("There was once upon a time a beautiful unicorn that loved to play with little girls...");
frame->add_child(label);
Button *button = memnew( Button );
button->set_pos( Point2( 20,20 ) );
button->set_size( Point2( 1,1 ) );
button->set_text("This is a biggie button");
frame->add_child( button );
#if 0
Sprite *tf = memnew( Sprite );
frame->add_child(tf);
Image img;
ImageLoader::load_image("LarvoClub.png",&img);
img.resize(512,512);
img.generate_mipmaps();
img.compress();
Ref<Texture> text = memnew( Texture );
text->create_from_image(img);
tf->set_texture(text);
tf->set_pos(Point2(50,50));
//tf->set_scale(Point2(0.3,0.3));
return;
#endif
Tree * tree = memnew( Tree );
tree->set_columns(2);
tree->set_pos( Point2( 230,210 ) );
tree->set_size( Point2( 150,250 ) );
TreeItem *item = tree->create_item();
item->set_editable(0,true);
item->set_text(0,"root");
item = tree->create_item( tree->get_root() );
item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
item->set_editable(0,true);
item->set_text(0,"check");
item->set_cell_mode(1, TreeItem::CELL_MODE_CHECK);
item->set_editable(1,true);
item->set_text(1,"check2");
item = tree->create_item( tree->get_root() );
item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE);
//.........这里部分代码省略.........