-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUIImage.cpp
More file actions
32 lines (28 loc) · 722 Bytes
/
UIImage.cpp
File metadata and controls
32 lines (28 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "UIImage.h"
UIImage::UIImage(UIContainer::Anchor _anchor, Tmpl8::vec2 _relPos, Tmpl8::Sprite* _sprite, float _size = 4)
{
anchor = _anchor;
relPos = _relPos;
sprite = _sprite;
size = _size;
width = sprite->GetWidth() * size;
height = sprite->GetHeight() * size;
}
void UIImage::Draw(Tmpl8::Surface* screen, Tmpl8::vec2 position)
{
sprite->DrawScaled(pos.x, pos.y, width, height, screen);
}
void UIImage::SetImage(Tmpl8::Sprite* _sprite) {
if (sprite != _sprite) {
sprite = _sprite;
width = sprite->GetWidth() * size;
height = sprite->GetHeight() * size;
isDirty = true;
}
}
void UIImage::SetFrame(int frame) {
if (sprite->Frames() > frame) {
sprite->SetFrame(frame);
isDirty = true;
}
}