-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathingamebutton.cpp
55 lines (46 loc) · 1.33 KB
/
ingamebutton.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "ingamebutton.h"
#include "filenames.h"
#define ALIAS_IN_GAME_BUTTON inGameButton
#define IN_GAME_BUTTON_WIDTH 64.0
#define IN_GAME_BUTTON_HEIGHT 16.0
InGameButton::InGameButton( Point ul, string target )
:LevelEntities( "BLOCK",
ul,
Point( ul.getX() + IN_GAME_BUTTON_WIDTH,
ul.getY() - IN_GAME_BUTTON_HEIGHT ),
"NULL" ),
Trigger()
{
resourceMgr = ResourceMgr::getInstance();
animationMgr = AnimationMgr::getInstance();
pressed = false;
this->target = target;
resourceMgr->loadImage( FILE_IN_GAME_BUTTON, "button" );
animationId = animationMgr->newAnimation( "button" );
}
InGameButton::~InGameButton()
{
resourceMgr->deleteImage( "button" );
animationMgr->removeAnimation( animationId );
resourceMgr->release();
animationMgr->release();
}
void InGameButton::press()
{
pressed = true;
trigger( target );
}
void InGameButton::unPress()
{
pressed = false;
unTrigger( target );
}
void InGameButton::draw()
{
if( pressed )
animationMgr->setAnimation( animationId, "pressed", "loop" );
else
animationMgr->setAnimation( animationId, "notPressed", "loop" );
animationMgr->update( animationId );
animationMgr->draw( animationId, true, uLeft );
}