feat(字体渲染): 添加字体管理和文本渲染功能
- 新增FontManager类用于管理字体资源 - 添加TextSprite类实现文本渲染功能 - 更新构建配置添加SDL2_ttf依赖 - 添加多种字体资源文件 - 修改窗口和相机初始化逻辑 - 更新Switch平台构建配置
This commit is contained in:
@@ -26,6 +26,9 @@
|
||||
|
||||
#include <frostbite2D/animation/animation.h>
|
||||
|
||||
#include <frostbite2D/2d/text_sprite.h>
|
||||
#include <frostbite2D/graphics/font_manager.h>
|
||||
|
||||
using namespace frostbite2D;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
@@ -59,6 +62,14 @@ int main(int argc, char **argv) {
|
||||
auto menuScene = MakePtr<Scene>();
|
||||
SceneManager::get().PushScene(menuScene);
|
||||
|
||||
FontManager::get().init();
|
||||
FontManager::get().registerFont("default",
|
||||
"assets/Fonts/VonwaonBitmap-12px.ttf", 12);
|
||||
auto text = TextSprite::create("你好世界", "default");
|
||||
text->SetPosition(100, 100);
|
||||
text->SetTextColor(Colors::Red);
|
||||
menuScene->AddChild(text);
|
||||
|
||||
auto ani = MakePtr<Animation>(
|
||||
"monster/event/bluemarble/goblin/animation_goblin2/move.ani");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user