refactor(actor): 重构Actor类以支持完整变换体系
重构Actor类,添加变换矩阵计算和父子关系处理 - 添加本地和世界变换矩阵计算 - 实现锚点、旋转、缩放等变换属性 - 添加父子关系变换继承 - 优化子节点管理,支持按ZOrder排序 - 添加透明度继承功能
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "SDL_log.h"
|
||||
#include "frostbite2D/types/type_math.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <frostbite2D/core/application.h>
|
||||
#include <frostbite2D/core/window.h>
|
||||
@@ -46,8 +47,13 @@ int main(int argc, char **argv) {
|
||||
// 尝试加载精灵
|
||||
auto sprite = Sprite::createFromFile("assets/player.png");
|
||||
if (sprite) {
|
||||
sprite->SetPosition(0, 0);
|
||||
menuScene->AddActor(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!");
|
||||
@@ -119,9 +125,9 @@ int main(int argc, char **argv) {
|
||||
|
||||
auto sprite1 = Sprite::createFromNpk("sprite/newtitle/nangua.img", 0);
|
||||
if (sprite1) {
|
||||
sprite1->SetPosition(0, 0);
|
||||
sprite1->SetScale(5.0f);
|
||||
menuScene->AddActor(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!");
|
||||
}
|
||||
@@ -137,13 +143,6 @@ int main(int argc, char **argv) {
|
||||
// SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to load sound!");
|
||||
// }
|
||||
|
||||
auto music = Music::loadFromNpk("sounds/ui/amazing_box.ogg");
|
||||
if (music) {
|
||||
music->play();
|
||||
} else {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to load music!");
|
||||
}
|
||||
|
||||
auto &audioDB = AudioDatabase::get();
|
||||
audioDB.loadFromFile("assets/audio.xml");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user