feat(动画系统): 实现动画系统基础功能
添加动画组件及相关数据结构,支持从PVF加载动画资源 实现动画播放、帧控制、插值逻辑等功能 更新主程序以测试动画系统
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
#include <frostbite2D/resource/audio_database.h>
|
||||
#include <frostbite2D/resource/sound_pack_archive.h>
|
||||
|
||||
#include <frostbite2D/animation/animation.h>
|
||||
|
||||
using namespace frostbite2D;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
@@ -43,9 +45,30 @@ int main(int argc, char **argv) {
|
||||
|
||||
// SDL_Log("Starting main loop...");
|
||||
|
||||
auto &pvf = PvfArchive::get();
|
||||
if (pvf.open("assets/Script.pvf")) {
|
||||
pvf.init();
|
||||
SDL_Log("PVF initialized successfully");
|
||||
}
|
||||
|
||||
NpkArchive &npk = NpkArchive::get();
|
||||
npk.setImagePackDirectory("assets/ImagePacks2");
|
||||
npk.setDefaultImg("sprite/interface/base.img", 0);
|
||||
npk.init();
|
||||
|
||||
auto menuScene = MakePtr<Scene>();
|
||||
SceneManager::get().PushScene(menuScene);
|
||||
|
||||
auto ani = MakePtr<Animation>(
|
||||
"monster/event/bluemarble/goblin/animation_goblin2/move.ani");
|
||||
|
||||
if (ani) {
|
||||
SDL_Log("Animation created successfully");
|
||||
ani->SetAnchor(Vec2(0.5f, 0.5f));
|
||||
ani->SetPosition(640, 360);
|
||||
menuScene->AddChild(ani);
|
||||
}
|
||||
|
||||
auto TestActor = MakePtr<Actor>();
|
||||
|
||||
menuScene->AddChild(TestActor);
|
||||
@@ -85,21 +108,15 @@ int main(int argc, char **argv) {
|
||||
return true;
|
||||
});
|
||||
|
||||
// // 尝试加载精灵
|
||||
// auto sprite = Sprite::createFromFile("assets/player.png");
|
||||
// if (sprite) {
|
||||
// sprite->SetPosition(320, 300);
|
||||
// sprite->SetOpacity(0.8f);
|
||||
// // sprite->SetAnchor(Vec2(0.5f, 0.5f));
|
||||
// // sprite->SetRotation(30.f);
|
||||
// sprite->SetZOrder(2000);
|
||||
// // sprite->SetScale(Vec2(-1.0f, 1.0f));
|
||||
// menuScene->AddChild(sprite);
|
||||
// SDL_Log("Sprite created and added to scene");
|
||||
// } else {
|
||||
// SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create sprite from file!");
|
||||
// }
|
||||
|
||||
auto sprite1 = Sprite::createFromNpk("sprite/newtitle/nangua.img", 0);
|
||||
if (sprite1) {
|
||||
sprite1->SetPosition(220, 10);
|
||||
// sprite1->SetScale(2.0f);
|
||||
menuScene->AddChild(sprite1);
|
||||
} else {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create sprite from NPK!");
|
||||
}
|
||||
|
||||
// // auto &archive = PvfArchive::get();
|
||||
// // if (archive.open("assets/Script.pvf")) {
|
||||
// // archive.init();
|
||||
@@ -159,19 +176,7 @@ int main(int argc, char **argv) {
|
||||
// SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to load background music!");
|
||||
// }
|
||||
|
||||
// NpkArchive &npk = NpkArchive::get();
|
||||
// npk.setImagePackDirectory("assets/ImagePacks2");
|
||||
// npk.setDefaultImg("sprite/interface/base.img", 0);
|
||||
// npk.init();
|
||||
|
||||
// auto sprite1 = Sprite::createFromNpk("sprite/newtitle/nangua.img", 0);
|
||||
// if (sprite1) {
|
||||
// sprite1->SetPosition(220, 10);
|
||||
// // sprite1->SetScale(2.0f);
|
||||
// sprite->AddChild(sprite1);
|
||||
// } else {
|
||||
// SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create sprite from NPK!");
|
||||
// }
|
||||
|
||||
// SoundPackArchive &archive = SoundPackArchive::get();
|
||||
// archive.setSoundPackDirectory("assets/SoundPacks");
|
||||
|
||||
Reference in New Issue
Block a user