Use the new notifiable system to scale the character.
This commit is contained in:
parent
85d57fd681
commit
dbf29f13d1
10 changed files with 28 additions and 16 deletions
|
@ -20,6 +20,7 @@
|
|||
#include "character.hpp"
|
||||
#include "sdlmain.hpp"
|
||||
#include "texture.hpp"
|
||||
#include <cassert>
|
||||
|
||||
namespace cloonel {
|
||||
///-------------------------------------------------------------------------
|
||||
|
@ -27,8 +28,13 @@ namespace cloonel {
|
|||
Character::Character (const std::string& parPath, SDLMain* parMain, float2 parSize) :
|
||||
Placeable(float2(0.0f)),
|
||||
Drawable(parSize),
|
||||
m_screenRatio(),
|
||||
m_screenRatioID(0),
|
||||
m_sdlmain(parMain),
|
||||
m_texture(new Texture(parPath, parMain, false))
|
||||
{
|
||||
assert(parMain);
|
||||
m_screenRatioID = parMain->RegisterForResChange(&m_screenRatio);
|
||||
}
|
||||
|
||||
///-------------------------------------------------------------------------
|
||||
|
@ -36,13 +42,19 @@ namespace cloonel {
|
|||
Character::Character (const std::string&& parPath, SDLMain* parMain, float2 parSize) :
|
||||
Placeable(float2(0.0f)),
|
||||
Drawable(parSize),
|
||||
m_screenRatio(),
|
||||
m_screenRatioID(0),
|
||||
m_sdlmain(parMain),
|
||||
m_texture(new Texture(parPath, parMain, false))
|
||||
{
|
||||
assert(parMain);
|
||||
m_screenRatioID = parMain->RegisterForResChange(&m_screenRatio);
|
||||
}
|
||||
|
||||
///-------------------------------------------------------------------------
|
||||
///-------------------------------------------------------------------------
|
||||
Character::~Character() noexcept {
|
||||
m_sdlmain->UnregisterForResChange(m_screenRatioID);
|
||||
}
|
||||
|
||||
///-------------------------------------------------------------------------
|
||||
|
@ -63,6 +75,6 @@ namespace cloonel {
|
|||
///-------------------------------------------------------------------------
|
||||
///-------------------------------------------------------------------------
|
||||
void Character::Draw() const {
|
||||
m_texture->Render(GetPos(), WidthHeight());
|
||||
m_texture->Render(GetPos(), WidthHeight(), m_screenRatio.Ratio());
|
||||
}
|
||||
} //namespace cloonel
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue