Example #1
0
void Node2D::set_global_transform(const Transform2D &p_transform) {

	CanvasItem *pi = get_parent_item();
	if (pi)
		set_transform(pi->get_global_transform().affine_inverse() * p_transform);
	else
		set_transform(p_transform);
}
Example #2
0
void Node2D::set_global_scale(const Size2 &p_scale) {

	CanvasItem *pi = get_parent_item();
	if (pi) {
		const Size2 parent_global_scale = pi->get_global_transform().get_scale();
		set_scale(p_scale / parent_global_scale);
	} else {
		set_scale(p_scale);
	}
}
Example #3
0
void Node2D::set_global_rotation(float p_radians) {

	CanvasItem *pi = get_parent_item();
	if (pi) {
		const float parent_global_rot = pi->get_global_transform().get_rotation();
		set_rotation(p_radians - parent_global_rot);
	} else {
		set_rotation(p_radians);
	}
}
Example #4
0
void Node2D::set_global_pos(const Point2& p_pos) {

	Matrix32 inv;
	CanvasItem *pi = get_parent_item();
	if (pi) {
		inv = pi->get_global_transform().affine_inverse();
		set_pos(inv.xform(p_pos));
	} else {
		set_pos(p_pos);
	}
}