修复 动画播放 错误的bug

This commit is contained in:
xsl
2025-12-22 14:55:00 +08:00
parent 29e0c1e9a8
commit c83f36c976
3 changed files with 41 additions and 8 deletions
+28 -3
View File
@@ -49,7 +49,7 @@ void CppAnimationFinishedCallback()
void CppCallback()
{
vector<string> motions = {"4", "11", "13"};
vector<string> motions = {"4"};
g_app->changeMotionList(motions, CppAnimationFinishedCallback, true);
}
@@ -88,6 +88,27 @@ void loadMotions(const std::string& filePath, std::map<std::string, Motion>& mot
}
}
bool threadRun = false;
// 线程要执行的函数
void threadFunction() {
int startTime = 0;
for (int i = 0; i < 500; ++i)
{
if (!threadRun)
{
break;
}
startTime += 100;
if (startTime == 10 * 1000)
{
vector<string> motions = { "5" };
g_app->changeMotionList(motions, CppAnimationFinishedCallback, true);
}
std::this_thread::sleep_for(std::chrono::milliseconds(100)); // 暂停200ms
}
}
int main() {
@@ -143,13 +164,17 @@ int main() {
MotionList s_motions;
s_motions.motions.push_back(motions["4"]);
s_motions.motions.push_back(motions["11"]);
s_motions.motions.push_back(motions["13"]);
s_motions.motions.push_back(motions["5"]);
//s_motions.motions.push_back(motions["13"]);
json j = s_motions;
auto s = j.dump();
app.preLoadMotionList(s, CppCallback);
threadRun = true;
std::thread t(threadFunction);
app.mainLoop();
threadRun = false;
t.join();
//try {
// app.mainLoop();
//} catch (const std::exception& e) {