godot エンジン C++ ソースコード徹底分析シリーズ 2

ソースコード研究の躍進を記録し、本日タイピング練習機能の基本モデルが完成しましたので、まずは動作効果を見てみましょう。

Godot ソース コードにタイピング練習用のデモを追加

これには、次の C++ コントロール ページの開発と習熟についての研究が必要です。結局のところ、私は長い間 C++ を使用していませんでした。まず、次のコードを見てみましょう。

	//第一排 显示文本  计时器 已完成个数  重新开始按钮
	HBoxContainer *version_info_first = memnew(HBoxContainer);
	// Add a dummy control node for spacing.
	Control *v_spacer_first = memnew(Control);
	version_info_first->add_child(v_spacer_first);
	hbc->add_child(version_info_first);
	VBoxContainer *hbc_first = memnew(VBoxContainer);
	hbc_first->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	hbc_first->set_alignment(BoxContainer::ALIGNMENT_CENTER);
	hbc_first->add_theme_constant_override("separation", 30 * EDSCALE);
	vbc->add_child(hbc_first);
	typing_label_time = memnew(Label);
	typing_label_time->set_text("timer:"); 
	version_info_first->add_child(typing_label_time);
	typing_label_count = memnew(Label);
	typing_label_count->set_text("complete"); 
	version_info_first->add_child(typing_label_count);
	typing_restart_btn = memnew(Button);
	typing_restart_btn->set_text("restart");
	typing_restart_btn->connect("pressed", callable_mp(this, &EditorApathysTyping::_version_button_pressed));
	version_info_first->add_child(typing_restart_btn); 

このようにして、テキスト ボックス、入力ボックス、ボタンとそれに対応するイベントが実現されますが、この後、ゆっくりと学習する必要がある機能がたくさんあります。

void EditorApathysTyping::_on_search_term_changed(const String &p_term) {
	ERR_PRINT(vformat("Blah: %s", p_term));
	String arr[17] = { "def", "div", "format", "enter", "tr", "table", "image", "td", "html", "float", "str", "var", "int", "else", "if", "for", "start" };
	int start = 0;
	int end = 16;

	int index = (rand() % (end - start)) + start;

	ERR_PRINT(vformat("Blah: %d", index));

	String should = typing_text_input_should->get_text();
	if (should == p_term) {
		typing_text_input_should->set_text(arr[index]);
		typing_text_input->set_text("");
	}
	if (should.count(should) < p_term.count(p_term)) {

	}

次のステップは、加工工場でパネルを検討することですが、これは難しいことではありますが、課題もあります。来て

私たちの目標にも注目してください。

メタバース オートボットの変換

おすすめ

転載: blog.csdn.net/xinshuai_1/article/details/131963852