Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SpriteFrame.cs
Go to the documentation of this file.
3
5
6public struct SpriteFrame
7{
8 public int PaddingX;
9
10 public int PaddingY;
11
12 private byte _currentColumn;
13
14 private byte _currentRow;
15
16 public readonly byte ColumnCount;
17
18 public readonly byte RowCount;
19
20 public byte CurrentColumn
21 {
22 get
23 {
24 return _currentColumn;
25 }
26 set
27 {
28 _currentColumn = value;
29 }
30 }
31
32 public byte CurrentRow
33 {
34 get
35 {
36 return _currentRow;
37 }
38 set
39 {
40 _currentRow = value;
41 }
42 }
43
44 public SpriteFrame(byte columns, byte rows)
45 {
46 PaddingX = 2;
47 PaddingY = 2;
49 _currentRow = 0;
50 ColumnCount = columns;
51 RowCount = rows;
52 }
53
54 public SpriteFrame(byte columns, byte rows, byte currentColumn, byte currentRow)
55 {
56 PaddingX = 2;
57 PaddingY = 2;
58 _currentColumn = currentColumn;
59 _currentRow = currentRow;
60 ColumnCount = columns;
61 RowCount = rows;
62 }
63
64 public SpriteFrame With(byte columnToUse, byte rowToUse)
65 {
66 SpriteFrame result = this;
67 result.CurrentColumn = columnToUse;
68 result.CurrentRow = rowToUse;
69 return result;
70 }
71
73 {
74 int num = texture.Width / ColumnCount;
75 int num2 = texture.Height / RowCount;
76 return new Rectangle(CurrentColumn * num, CurrentRow * num2, num - ((ColumnCount != 1) ? PaddingX : 0), num2 - ((RowCount != 1) ? PaddingY : 0));
77 }
78}
SpriteFrame With(byte columnToUse, byte rowToUse)
Rectangle GetSourceRectangle(Texture2D texture)
SpriteFrame(byte columns, byte rows)
SpriteFrame(byte columns, byte rows, byte currentColumn, byte currentRow)