136 if(_y == -1)
137 D3DXMatrixTranslation(&matMove2,0,GetHight(), 0);
138
139 if(_x!=-1&&_y!=-1)
140 D3DXMatrixTranslation(&matMove,0,0, 0);
141
142 //平移
143 D3DXMatrixTranslation(&matMove1,m_position.x ,m_position.y, 0);
144
145 //计算结果
146 if(_x == -1)
147 matResult = matScall*matMove*matMove1 ;
148
149 if(_y == -1)
150 matResult = matScall*matMove2*matMove1 ;
151
152 if(_x!=-1&&_y!=-1)
153 matResult = matScall*matMove ;
154
155 if(_x ==-1&&_y == -1)
156 matResult = matScall*matMove*matMove2*matMove1 ;
157
158 if(_x == 1&&_y == 1)
159 matResult = matScall*matMove*matMove1;
160
161 if(_x>1)
162 matResult = matScall*matMove*matMove1;
163 if(_y>1)
164 matResult = matScall*matMove*matMove1;
165
166 //转换
167 CDx9App::GetDx9App().GetD3dSprite()->SetTransform(&matResult);
168
169 if(CDx9App::GetDx9App().GetD3dSprite())
170 {
171 CDx9App::GetDx9App().GetD3dSprite()->Draw(m_tex->GetTex(),&temprect,&m_vcenter,&D3DXVECTOR3(0.0,0,0),-1);
172 }
173 }
174
175 void CAnimation::NextFrame()
176 {
177 if(m_isplay)
178 {
179 m_timecount++;
180
181 if(m_timecount>1000)
182 m_timecount = 0;
183
184 if(m_timecount%m_playerSpeed == 0)
185 m_curframe++;
186
187 if(m_curframe>m_framemax-1)
188 {
189 m_curation++;
190
191 if(m_curation>m_ationmax-1)
192 {
193 m_curation = 0;
194
195 m_curframe = 0;
196
197 m_isplay = false;
198 }
199
200 m_curframe = 0;
201 }
202 }
203 }
204
文件名:DxSprite.h
1 #ifndef DXSPRITE_H
2 #define DXSPRITE_H
3 #include "DxTexture.h"
4 #include "Dx9App.h"
5
6 class CDxSprite: public CResObject
7 {
9
10 //0 id 1 纹理指针 2 纹理上的x 3纹理上的y 4 需要截取的宽度 5需要截取的高度
11 CDxSprite(short _id, CDxTexture *_tex, UINT _type, UINT _tx, UINT _ty, UINT _tw, UINT _th);
12
13 virtual ~CDxSprite(void);
14
15 //绘制
16 virtual void Render(DFPOINT _pos);
17
18 //绘制-角度
19 virtual void Render(DFPOINT _pos, DOUBLE _Angle);
20
21 //绘制-缩放+翻转 x=-1为x轴翻转 y=-1为y轴翻转
22 virtual void Render(DFPOINT _pos, FLOAT _x, FLOAT _y);
23
24 //设置精灵宽
25 void SetWidth(UINT _width)
26 {
27 m_width = _width;
28 }
29
30 //设置精灵高
31 void SetHeight(UINT _height)
32 {
33 m_hight = _height;
34 }
35
36 //获取精灵的宽
37 UINT GetWidth() const
38 {
39 return m_width;
40 }
41
42 //获取精灵的高
43 UINT GetHight() const
44 {
45 return m_hight;
46 }
47
48 protected:
49 CDxSprite(void);
50
51 //纹理指针
52 CDxTexture *m_tex;
53
54 //矩形
55 RECT m_rect;
56
57 D3DXVECTOR3 m_vcenter;
58
59 D3DXVECTOR3 m_position;
60
61 //精灵宽
62 UINT m_width;
63
64 //精灵高
65 UINT m_hight;
66
67 //翻转
68 OVERTURN m_overturn;
69 };
70
71 #endif
72
文件名:DXSprite.cpp
1 #include "DxSprite.h"
2 #include "DxTexture.h"
3
4 CDxSprite::CDxSprite(void)
5 {
6
7 }
8
9 CDxSprite::~CDxSprite(void)
10 {
11