精灵动画 ============================== 精灵动画与纹理唯一的不同之处在于, 精灵纹理使用一张精灵图作为纹理资源, 并且需要被附加处理的逻辑,包括帧的尺寸, 每一帧播放的时长等。 接下来的代码展示如何渲染一个精灵动画 :: // 加载纹理资源 r->LoadTexture("texture", Path::GeneratePath(A_IMAGE, "Blue_witch/B_witch_charge.png").c_str() ); // 创建一个实体 Entity one = w->CreateEntity(); // 绑定精灵动画组件 w->AtachComp(one, SpriteAnimComp{ &r->GetTexture("texture"), 150, 150, 1, 8, 0.2 }); w->AtachComp(one, TransformComp{ glm::vec2(100, 100), glm::vec2(150, 150), 0.0f }); w->AtachComp(one, ColorComp{ glm::vec3(1.0f, 1.0f, 1.0f) }); w->AtachComp(one, AABBComp{ 150, 150 });