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


C++ CanvasItem::get_canvas_item方法代码示例

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


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

示例1: _enter_canvas

void CanvasItem::_enter_canvas() {

	if ((!get_parent() || !get_parent()->cast_to<CanvasItem>()) || toplevel) {

		Node *n = this;
		Viewport *viewport=NULL;
		canvas_layer=NULL;

		while(n) {

			if (n->cast_to<Viewport>()) {

				viewport = n->cast_to<Viewport>();
				break;
			}
			if (!canvas_layer && n->cast_to<CanvasLayer>()) {

				canvas_layer = n->cast_to<CanvasLayer>();
			}
			n=n->get_parent();
		}

		RID canvas;
		if (canvas_layer)
			canvas=canvas_layer->get_world_2d()->get_canvas();
		else
			canvas=viewport->find_world_2d()->get_canvas();

		VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,canvas);

		group = "root_canvas"+itos(canvas.get_id());

		add_to_group(group);
		get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_raise_self");

	} else {

		CanvasItem *parent = get_parent_item();
		VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,parent->get_canvas_item());
		parent->_queue_sort_children();
	}

	pending_update=false;
	update();

	notification(NOTIFICATION_ENTER_CANVAS);

}
开发者ID:AMG194,项目名称:godot,代码行数:48,代码来源:canvas_item.cpp

示例2: _enter_canvas

void CanvasItem::_enter_canvas() {

	if ((!Object::cast_to<CanvasItem>(get_parent())) || toplevel) {

		Node *n = this;

		canvas_layer = NULL;

		while (n) {

			canvas_layer = Object::cast_to<CanvasLayer>(n);
			if (canvas_layer) {
				break;
			}
			n = n->get_parent();
		}

		RID canvas;
		if (canvas_layer)
			canvas = canvas_layer->get_world_2d()->get_canvas();
		else
			canvas = get_viewport()->find_world_2d()->get_canvas();

		VisualServer::get_singleton()->canvas_item_set_parent(canvas_item, canvas);

		group = "root_canvas" + itos(canvas.get_id());

		add_to_group(group);
		if (canvas_layer)
			canvas_layer->reset_sort_index();
		else
			get_viewport()->gui_reset_canvas_sort_index();

		get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE, group, "_toplevel_raise_self");

	} else {

		CanvasItem *parent = get_parent_item();
		canvas_layer = parent->canvas_layer;
		VisualServer::get_singleton()->canvas_item_set_parent(canvas_item, parent->get_canvas_item());
		VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_index());
	}

	pending_update = false;
	update();

	notification(NOTIFICATION_ENTER_CANVAS);
}
开发者ID:brakhane,项目名称:godot,代码行数:48,代码来源:canvas_item.cpp


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