UGDK
0.4.1
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
drawable.h
Go to the documentation of this file.
1
#ifndef HORUSEYE_FRAMEWORK_DRAWABLE_H_
2
#define HORUSEYE_FRAMEWORK_DRAWABLE_H_
3
4
#include <
ugdk/math/vector2D.h
>
5
6
namespace
ugdk {
7
namespace
graphic {
8
9
class
Drawable
{
10
public
:
11
enum
HookPoint
{
12
TOP_LEFT
,
TOP
,
TOP_RIGHT
,
13
LEFT
,
CENTER
,
RIGHT
,
14
BOTTOM_LEFT
,
BOTTOM
,
BOTTOM_RIGHT
15
};
16
virtual
~Drawable
() {};
17
18
virtual
void
Update
(
double
dt) = 0;
19
virtual
void
Draw
()
const
= 0;
20
virtual
const
Vector2D
&
size
()
const
= 0;
21
22
void
set_hotspot
(
const
Vector2D
&
hotspot
) {
hotspot_
=
hotspot
; }
23
void
set_hotspot
(
const
HookPoint
& hook) {
24
switch
(hook) {
25
case
TOP_LEFT
:
hotspot_
=
Vector2D
( 0.0, 0.0);
break
;
26
case
TOP
:
hotspot_
=
Vector2D
(
size
().x * 0.5, 0.0);
break
;
27
case
TOP_RIGHT
:
hotspot_
=
Vector2D
(
size
().x, 0.0);
break
;
28
case
LEFT
:
hotspot_
=
Vector2D
( 0.0,
size
().y * 0.5);
break
;
29
case
CENTER
:
hotspot_
=
size
() * 0.5;
break
;
30
case
RIGHT
:
hotspot_
=
Vector2D
(
size
().x,
size
().y * 0.5);
break
;
31
case
BOTTOM_LEFT
:
hotspot_
=
Vector2D
( 0.0,
size
().y);
break
;
32
case
BOTTOM
:
hotspot_
=
Vector2D
(
size
().x * 0.5,
size
().y);
break
;
33
case
BOTTOM_RIGHT
:
hotspot_
=
size
();
break
;
34
}
35
}
36
37
const
double
width
()
const
{
return
size
().
x
; }
38
const
double
height
()
const
{
return
size
().
y
; }
39
const
Vector2D
&
hotspot
()
const
{
return
hotspot_
; }
40
41
protected
:
42
Drawable
() {}
43
44
ugdk::Vector2D
hotspot_
;
45
};
46
47
}
// namespace graphic
48
}
// namespace ugdk
49
50
#endif
src
ugdk
graphic
drawable.h
Generated on Sat Oct 13 2012 02:25:11 for UGDK by
1.8.2