-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrameImage.cs
91 lines (79 loc) · 1.88 KB
/
FrameImage.cs
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
public class FrameImage
{
public int frameWidth;
public int frameHeight;
public int nFrame;
public Image imgFrame;
private int[] pos;
private int totalHeight;
private Image[] imgList;
private bool isRotate;
public FrameImage(Image img, int width, int height)
{
imgFrame = img;
frameWidth = width;
frameHeight = height;
totalHeight = Image.getImageHeight(img);
nFrame = totalHeight / height;
pos = new int[nFrame];
for (int i = 0; i < nFrame; i++)
{
pos[i] = i * height;
}
}
public FrameImage(Image img, int n)
{
imgFrame = img;
frameWidth = img.getWidth();
frameHeight = img.getHeight();
nFrame = n;
imgList = new Image[nFrame];
isRotate = true;
int num = 360 / n;
for (int i = 1; i < nFrame; i++)
{
int num2 = i * num;
int num3 = num2;
}
}
public void drawRegionFrame(int idx, int x, int y, int trans, int anchor, mGraphics g, int bulletID, int n)
{
g.drawRegion(imgFrame, 0, (bulletID * n + idx) * imgFrame.getWidth(), imgFrame.getWidth(), imgFrame.getWidth(), trans, x, y, anchor);
}
public void drawFrame(int idx, int x, int y, int trans, int anchor, mGraphics g)
{
if (!isRotate)
{
if (idx >= 0 && idx < nFrame)
{
g.drawRegion(imgFrame, 0, pos[idx], frameWidth, frameHeight, trans, x, y, anchor);
}
}
else if (idx >= 0 && idx < nFrame)
{
switch (idx * (360 / nFrame))
{
case 0:
g.drawImage(imgFrame, x, y, 3);
break;
case 90:
g.drawRegion(imgFrame, 0, 0, frameWidth, frameHeight, 5, x, y, anchor);
break;
case 270:
g.drawRegion(imgFrame, 0, 0, frameWidth, frameHeight, 6, x, y, anchor);
break;
case 180:
g.drawRegion(imgFrame, 0, 0, frameWidth, frameHeight, 3, x, y, anchor);
break;
default:
g.drawRegion(imgList[idx], 0, 0, frameWidth, frameHeight, trans, x, y, anchor);
break;
}
}
}
public void unload()
{
imgFrame = null;
pos = null;
}
}