-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimator.cpp
More file actions
93 lines (80 loc) · 2.25 KB
/
Animator.cpp
File metadata and controls
93 lines (80 loc) · 2.25 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "stdafx.h"
#include "Animator.h"
Animator::Animator()
{
}
Animator::~Animator()
{
}
void Animator::Init()
{
renderer = gameObject->GetComponent<Renderer>();
if (renderer == nullptr) {
throw "Animator에서 발생 : 게임 오브젝트에 Renderer컴포넌트가 없습니다";
}
}
void Animator::Update()
{
if (curClip == nullptr)
return;
frameTime = frameTime + TIMEMANAGER->getElapsedTime();
if (frameTime >= curClip->frameTerm) {
BitBlt(renderer->memDC, 0, 0, curClip->frameWidth, curClip->frameHeight,
curClip->wholeDC, curClip->frameWidth * curClip->currentFrame, 0, SRCCOPY);
curClip->currentFrame++;
if (curClip->currentFrame == curClip->frameNum) {
if (curClip->isLoop == true)
curClip->currentFrame = 0;
else {
curClip->currentFrame = curClip->frameNum - 1;
for (transactionIter = transactionMap.begin(); transactionIter != transactionMap.end(); transactionIter++) {
if (transactionIter->second.startClip == curClip) {
SetClip(transactionIter->second.nextClip);
}
}
}
}
frameTime = 0;
}
}
void Animator::Render()
{
}
void Animator::SetClip(AnimationClip* newClip)
{
preClip = curClip;
curClip = newClip;
curClip->currentFrame = 0;
frameTime = 0;
renderer->Resize(curClip->frameWidth, curClip->frameHeight);
BitBlt(renderer->memDC, 0, 0, curClip->frameWidth, curClip->frameHeight,
curClip->wholeDC, 0, 0, SRCCOPY);
}
void Animator::SetClip(AnimationClip* newClip, int startFrame)
{
preClip = curClip;
curClip = newClip;
curClip->currentFrame = startFrame;
frameTime = 0;
renderer->Resize(curClip->frameWidth, curClip->frameHeight);
BitBlt(renderer->memDC, 0, 0, curClip->frameWidth, curClip->frameHeight,
curClip->wholeDC, curClip->currentFrame * curClip->frameWidth, 0, SRCCOPY);
}
void Animator::AddClip(string clipName, AnimationClip* newClip)
{
clipMap.insert(make_pair(clipName, newClip));
}
AnimationClip* Animator::GetClip(string clipName)
{
map<string, AnimationClip*>::iterator iter;
iter = clipMap.find(clipName);
if (iter != clipMap.end()) {
return iter->second;
}
return nullptr;
}
void Animator::AddTransaction(string name, AnimationClip* startClip, AnimationClip* nextClip)
{
TRANSACTION newTransaction = { startClip, nextClip };
transactionMap.insert(make_pair( name, newTransaction));
}