Incremental Engine  1.0.6
A 2D Game Engine to create Idle Games
IncrementalEngine::Sprite Class Reference

#include <Sprite.h>

Inheritance diagram for IncrementalEngine::Sprite:
IncrementalEngine::Actor IncrementalEngine::Transformable IncrementalEngine::Drawable IncrementalEngine::Button IncrementalEngine::Panel

Public Member Functions

 Sprite ()
 
virtual ~Sprite () override
 
void SetTexture (Texture *texture)
 
void ClearTexture ()
 
virtual FloatRect GetLocalBounds () override
 
virtual void Update (float dt) override
 
virtual HRESULT Draw (ID3D11DeviceContext *deviceContext) override
 
- Public Member Functions inherited from IncrementalEngine::Actor
virtual ~Actor ()
 
virtual void Init ()
 
void UpdateRecursive (float dt)
 
HRESULT DrawRecursive (ID3D11DeviceContext *deviceContext)
 
FloatRect GetGlobalBounds ()
 
void Center ()
 
const Transform GetWorldTransform ()
 
const D3DXVECTOR2 GetWorldPosition ()
 
const D3DXVECTOR2 GetWorldScale ()
 
const float GetWorldRotation ()
 
void SetWorldPosition (D3DXVECTOR2 value)
 
virtual void SetPosition (float x, float y) override
 
virtual void SetPosition (const D3DXVECTOR2 &position) override
 
virtual const D3DXVECTOR2 & GetPosition () const override
 
ActorGetParent () const
 
virtual void SetParent (Actor *value, const bool fixWorldPosition=true)
 
void SetActive (bool active)
 
bool IsActive ()
 
- Public Member Functions inherited from IncrementalEngine::Transformable
 Transformable ()
 
virtual void SetScale (float factorX, float factorY)
 
virtual void SetScale (const D3DXVECTOR2 &factors)
 
virtual void SetOrigin (float x, float y)
 
virtual void SetOrigin (const D3DXVECTOR2 &origin)
 
virtual void SetRotation (float angle)
 
virtual float GetRotation () const
 
virtual const D3DXVECTOR2 & GetScale () const
 
virtual const D3DXVECTOR2 & GetOrigin () const
 
void Move (float offsetX, float offsetY)
 
void Move (const D3DXVECTOR2 &offset)
 
void Rotate (float angle)
 
void Scale (float factorX, float factorY)
 
void Scale (const D3DXVECTOR2 &factor)
 
const TransformGetTransform () const
 
const TransformGetInverseTransform () const
 

Private Attributes

TextureBase_texture
 

Additional Inherited Members

- Protected Member Functions inherited from IncrementalEngine::Drawable
void CopyParameters (Drawable *drawable)
 
- Protected Attributes inherited from IncrementalEngine::Transformable
bool _transformNeedUpdate
 
- Protected Attributes inherited from IncrementalEngine::Drawable
RenderWindow_renderWindow
 
ShaderManager_shaderManager
 
ID3D11Device * _device
 

Detailed Description

Definition at line 9 of file Sprite.h.

Constructor & Destructor Documentation

◆ Sprite()

IncrementalEngine::Sprite::Sprite ( )

Definition at line 6 of file Sprite.cpp.

6  :
7  _texture(NULL)
8  {
9  }

◆ ~Sprite()

IncrementalEngine::Sprite::~Sprite ( )
overridevirtual

Definition at line 11 of file Sprite.cpp.

12  {
13  CHECKED_DELETE(_texture);
14  }

Member Function Documentation

◆ ClearTexture()

void IncrementalEngine::Sprite::ClearTexture ( )

Definition at line 41 of file Sprite.cpp.

42  {
43  CHECKED_DELETE(_texture);
44  }

◆ Draw()

HRESULT IncrementalEngine::Sprite::Draw ( ID3D11DeviceContext *  deviceContext)
overridevirtual

Reimplemented from IncrementalEngine::Actor.

Definition at line 63 of file Sprite.cpp.

64  {
65  HRESULT result;
66 
67  if (_texture != nullptr)
68  {
69  result = _texture->Draw(deviceContext);
70 
71  if (FAILED(result))
72  {
73  return CO_E_ERRORINAPP;
74  }
75  }
76 
77  return S_OK;
78  }

◆ GetLocalBounds()

FloatRect IncrementalEngine::Sprite::GetLocalBounds ( )
overridevirtual

Reimplemented from IncrementalEngine::Actor.

Definition at line 46 of file Sprite.cpp.

47  {
48  FloatRect bounds = {
49  0.f,
50  0.f,
51  _texture->GetSize().x,
52  _texture->GetSize().y
53  };
54 
55  return bounds;
56  }

◆ SetTexture()

void IncrementalEngine::Sprite::SetTexture ( Texture texture)

Definition at line 16 of file Sprite.cpp.

17  {
18  if (_texture != nullptr)
19  {
20  if (_texture->GetTexture() == texture)
21  {
22  return;
23  }
24 
25  CHECKED_DELETE(_texture);
26  }
27 
28  auto bitmap = new Bitmap;
29  CopyParameters(bitmap);
30  HRESULT result = bitmap->Create(texture);
31 
32  if (FAILED(result))
33  {
34  throw;
35  }
36 
37  _texture = bitmap;
38  Center();
39  }

◆ Update()

void IncrementalEngine::Sprite::Update ( float  dt)
overridevirtual

Reimplemented from IncrementalEngine::Actor.

Reimplemented in IncrementalEngine::Panel, and IncrementalEngine::Button.

Definition at line 58 of file Sprite.cpp.

59  {
61  }

Member Data Documentation

◆ _texture

TextureBase* IncrementalEngine::Sprite::_texture
private

Definition at line 24 of file Sprite.h.

IncrementalEngine::Drawable::Draw
virtual HRESULT Draw(ID3D11DeviceContext *deviceContext)=0
IncrementalEngine::TextureBase::GetTexture
Texture * GetTexture()
Definition: TextureBase.cpp:22
IncrementalEngine::Actor::GetWorldTransform
const Transform GetWorldTransform()
Definition: Actor.cpp:93
IncrementalEngine::Sprite::_texture
TextureBase * _texture
Definition: Sprite.h:24
IncrementalEngine::Drawable::CopyParameters
void CopyParameters(Drawable *drawable)
Definition: Drawable.h:20
IncrementalEngine::TextureBase::GetSize
D3DXVECTOR2 GetSize()
Definition: TextureBase.cpp:27
IncrementalEngine::Actor::Center
void Center()
Definition: Actor.cpp:77
IncrementalEngine::TextureBase::Update
void Update(Transform transform, FloatRect bounds)
Definition: TextureBase.cpp:16
IncrementalEngine::Sprite::GetLocalBounds
virtual FloatRect GetLocalBounds() override
Definition: Sprite.cpp:46