-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpriteCommander.cpv
99 lines (78 loc) · 2.51 KB
/
SpriteCommander.cpv
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
94
95
// Feature source code generation begins here...
INotificationId SpriteCommander::spriteSequenceId = "SpriteCommander::spriteSequence";
INotificationId SpriteCommander::selectedSpriteNumberId = "SpriteCommander::selectedSpriteNumber";
INotificationId SpriteCommander::fastCanvasId = "SpriteCommander::fastCanvas";
INotificationId SpriteCommander::fastMovementMultiplierId = "SpriteCommander::fastMovementMultiplier";
IVSequence<Sprite*>* SpriteCommander::spriteSequence() const
{
return iSpriteSequence;
}
SpriteCommander& SpriteCommander::setSpriteSequence(IVSequence<Sprite*>* aSpriteSequence)
{
if (!(iSpriteSequence == aSpriteSequence))
{
iSpriteSequence = aSpriteSequence;
notifyObservers(INotificationEvent(SpriteCommander::spriteSequenceId, *this));
} // endif
return *this;
}
int SpriteCommander::selectedSpriteNumber() const
{
return iSelectedSpriteNumber;
}
SpriteCommander& SpriteCommander::setSelectedSpriteNumber(int aSelectedSpriteNumber)
{
if (!(iSelectedSpriteNumber == aSelectedSpriteNumber))
{
iSelectedSpriteNumber = aSelectedSpriteNumber;
notifyObservers(INotificationEvent(SpriteCommander::selectedSpriteNumberId, *this));
} // endif
return *this;
}
FastCanvas* SpriteCommander::fastCanvas() const
{
return iFastCanvas;
}
SpriteCommander& SpriteCommander::setFastCanvas(FastCanvas* aFastCanvas)
{
if (!(iFastCanvas == aFastCanvas))
{
iFastCanvas = aFastCanvas;
notifyObservers(INotificationEvent(SpriteCommander::fastCanvasId, *this));
} // endif
return *this;
}
IPoint SpriteCommander::fastMovementMultiplier() const
{
return iFastMovementMultiplier;
}
SpriteCommander& SpriteCommander::setFastMovementMultiplier(const IPoint& aFastMovementMultiplier)
{
if (!(iFastMovementMultiplier == aFastMovementMultiplier))
{
iFastMovementMultiplier = aFastMovementMultiplier;
notifyObservers(INotificationEvent(SpriteCommander::fastMovementMultiplierId, *this));
} // endif
return *this;
}
// Feature source code generation ends here.
Sprite & SpriteCommander::selectedSprite () const
{
return *iSpriteSequence->elementAtPosition (iSelectedSpriteNumber);
}
SpriteCommander& SpriteCommander::advanceFrame(int numFrames)
{
selectedSprite().advanceFrame (numFrames);
iFastCanvas->draw();
return *this;
}
SpriteCommander& SpriteCommander::move(IPoint const& offset)
{
selectedSprite().move(offset);
iFastCanvas->draw();
return *this;
}
SpriteCommander& SpriteCommander::moveFast(IPoint const& offset)
{
return move (offset * iFastMovementMultiplier);
}