Example #1
0
bool CollisionObject2D::_set(const StringName& p_name, const Variant& p_value) {
	String name=p_name;

	if (name=="shape_count") {

		shapes.resize(p_value);
		_update_shapes();
		_change_notify();

	} else if (name.begins_with("shapes/")) {

		int idx=name.get_slice("/",1).to_int();
		String what=name.get_slice("/",2);
		if (what=="shape")
			set_shape(idx,RefPtr(p_value));
		else if (what=="transform")
			set_shape_transform(idx,p_value);
		else if (what=="trigger")
			set_shape_as_trigger(idx,p_value);
	} else
		return false;

	return true;


}
Example #2
0
bool CollisionObject2D::_set(const StringName &p_name, const Variant &p_value) {
	String name = p_name;

	if (name.begins_with("shapes/")) {

		int idx = name.get_slicec('/', 1).to_int();
		String what = name.get_slicec('/', 2);
		if (what == "shape") {
			if (idx >= shapes.size())
				add_shape(RefPtr(p_value));
			else
				set_shape(idx, RefPtr(p_value));
		} else if (what == "transform")
			set_shape_transform(idx, p_value);
		else if (what == "trigger")
			set_shape_as_trigger(idx, p_value);
	} else
		return false;

	return true;
}