I wrote this code to add a slider to the text in the game but the text is not displayed. where is the mistake?
areaTesto = new TextNode(“EsempioInterazione”);
areaTesto->set_text(“Qui ci metto la comunicazione del png”);
areaTesto->set_frame_as_margin(1, 1, 1, 1);
areaTesto->set_card_color(1, 1, 1, 1);
areaTesto->set_card_as_margin(0, 0, 0, 0);
areaTesto->set_card_decal(true);
areaTesto->set_text_color(0, 0, 0, 1);
Slider=new PGSliderBar("MySliderBar");
// Setup, feeding the constructor with (bool vertical,float lenght,float width,float bevel)
Slider->setup_slider(false,0.1,0.1,0); // 'rail' properties
Slider->set_range(0,1);
Slider->set_value(0.5);
Slider->set_text_node(areaTesto);
// Setup scroll bar (the 'moving thumb button' including left and right button)
Slider->setup_scroll_bar(true,0.35,0.05,false);
NodePath SliderNP=window->get_aspect_2d().attach_new_node(Slider);
SliderNP.set_pos(-1,0,-0.7);
SliderNP.set_scale(2);
No I do not have a good result
areaTesto2 = new TextNode(“EsempioInterazione”);
areaTesto2->set_text(“Qui ci metto la comunicazione del png”);
areaTesto2->set_frame_as_margin(1, 1, 1, 1);
areaTesto2->set_card_color(1, 1, 1, 1);
areaTesto2->set_card_as_margin(0, 0, 0, 0);
areaTesto2->set_card_decal(true);
areaTesto2->set_text_color(0, 0, 1, 1);
areaTesto2->set_text_scale(1);
Slider=new PGSliderBar("MySliderBar");
// Setup, feeding the constructor with (bool vertical,float lenght,float width,float bevel)
Slider->setup_slider(false,0.1,0.1,0); // 'rail' properties
Slider->set_range(0,1);
Slider->set_value(0.5);
Slider->set_text_node(areaTesto2);
//Slider->add_child(areaTesto, 0, Thread *current = Thread::get_current_thread());
// Setup scroll bar (the 'moving thumb button' including left and right button)
Slider->setup_scroll_bar(true,0.35,0.05,false);
nodePathTesto = window->get_aspect_2d().attach_new_node(areaTesto2);
nodePathTesto.set_pos(0,0,0);
nodePathTesto.set_scale(1);
NodePath SliderNP=window->get_aspect_2d().attach_new_node(Slider);
SliderNP.set_pos(-1,0,-0.7);
//devo qui implementare una piccola interfaccia che comunichi
// e permetta di scegliere delle opzioni
PGItem::set_text_node() doesn’t do what you think it does. It is a global setting for all PGItems that only specifies the parameters that are used when a label is generated internally; it does not specify a text label for each individual item.
PGSlider does not have a facility for creating a text label internally. Instead, you should create a TextNode and parent it to the slider, positioning and scaling it appropriately yourself. Do not call set_text_node().