#include "RLabel.h" #include "RGame.h" RLabel::RLabel() { } RLabel::~RLabel() { } RLabel* RLabel::create(const std::string& str, float fntSize) { RLabel * ret = new (std::nothrow) RLabel(); if (ret && ret->init(str, fntSize)) { ret->autorelease(); return ret; } delete ret; return nullptr; } bool RLabel::init(const std::string& str, float fontSize) { #if (NEW_LABEL == 1) string path = ""; float scale = 0.0f; if(fontSize <= 30){ path = RGame::getInstance()->getSmallFont(); scale = fontSize / 24.0f; }else if( fontSize <= 60){ path = RGame::getInstance()->getMediumFont(); scale = fontSize / 48.0f; }else{ path = RGame::getInstance()->getLargeFont(); scale = fontSize / 96.0f; } setBMFontFilePath(path); setHorizontalAlignment(TextHAlignment::CENTER); setString(str); setScale(scale); #else setFontName(RLABEL_FONT); setString(str); setFontSize(fontSize); setHorizontalAlignment(TextHAlignment::CENTER); #endif return true; }