Use the new notifiable system to scale the character.

This commit is contained in:
King_DuckZ 2014-03-20 11:46:20 +01:00
parent 85d57fd681
commit dbf29f13d1
10 changed files with 28 additions and 16 deletions

View file

@ -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