14 {
15 m_framemax = _framemax;
16
17 m_ationmax = _ationmax;
18
19 m_curframe = 0;
20
21 m_curation = 0;
22
23 m_playerSpeed = _playerspeed;
24 }
25
26 void CAnimation::UpData(float _time)
27 {
28 NextFrame();
29 }
30
31 void CAnimation::Render(DFPOINT _pos)
32 {
33 //精灵的坐标x
34 m_position.x = _pos.x;
35
36 //精灵的左边y
37 m_position.y = _pos.y;
38
39 //frame的变化
40 RECT temprect;
41
42 temprect.left = m_rect.left + m_curframe*m_width;
43
44 temprect.right = m_rect.right + m_curframe*m_width;
45
46 //ation的变化
47 temprect.top = m_rect.top + m_curation*m_hight;
48
49 temprect.bottom = m_rect.bottom + m_curation*m_hight;
50
51 if(CDx9App::GetDx9App().GetD3dSprite())
52 {
53 CDx9App::GetDx9App().GetD3dSprite()->Draw(m_tex->GetTex(),&temprect,
54 &m_vcenter,&m_position,-1);
55 }
56 }
57
58 void CAnimation::Render(DFPOINT _pos,DOUBLE _Angle)
59 {
60 //旋转,平移矩阵
61 D3DXMATRIX matWorld,matRotationZ,matWorld1;
62
63 CDx9App::GetDx9App().GetD3dSprite()->SetTransform(&matRotationZ);
64
65 //精灵的坐标x
66 m_position.x = _pos.x;
67
68 //精灵的左边y
69 m_position.y = _pos.y;
70
71 //frame的变化
72 RECT temprect;
73
74 temprect.left = m_rect.left + m_curframe*m_width;
76 temprect.right = m_rect.right + m_curframe*m_width;
77
78 //ation的变化
79 temprect.top = m_rect.top + m_curation*m_hight;
80 temprect.bottom = m_rect.bottom + m_curation*m_hight;
81
82 FLOAT x = (GetWidth()/2);
83
84 FLOAT y = (GetHight()/2);
85
86 D3DXMatrixTranslation(&matWorld, -x, -y,0);
87
88 D3DXMatrixRotationZ(&matRotationZ,(2*PAI) - _Angle);
89
90 D3DXMatrixTranslation(&matWorld1,m_position.x,m_position.y,0);
91
92 matWorld = matWorld*matRotationZ*matWorld1 ;
93
94 CDx9App::GetDx9App().GetD3dSprite()->SetTransform(&matWorld);
95
96 if(CDx9App::GetDx9App().GetD3dSprite())
97 {
98 CDx9App::GetDx9App().GetD3dSprite()->Draw(m_tex->GetTex(),&temprect,&m_vcenter,&D3DXVECTOR3(0,0,0),-1);
99 }
100 }
101
102 void CAnimation::Render(DFPOINT _pos,FLOAT _x,FLOAT _y)
103 {
104 //旋转,平移矩阵
105 D3DXMATRIX matScall, matMove, matMove1,matMove2,matResult;
106
107 //精灵的坐标x
108 m_position.x = _pos.x;
109
110 //精灵的左边y
111 m_position.y = _pos.y;
112
113 //frame的变化
114 RECT temprect;
115
116 temprect.left = m_rect.left + m_curframe*m_width;
117
118 temprect.right = m_rect.right + m_curframe*m_width;
119
120 //ation的变化
121 temprect.top = m_rect.top + m_curation*m_hight;
122
123 temprect.bottom = m_rect.bottom + m_curation*m_hight;
124
125 FLOAT x = (GetWidth()/2);
126
127 FLOAT y = (GetHight()/2);
128
129 //缩放
130 D3DXMatrixScaling(&matScall, _x ,_y, 0);
131
132 //为了让精灵在反转的时候坐标不改变做了平移处理
133 if(_x == -1)
134 D3DXMatrixTranslation(&matMove,GetWidth(),0, 0);
135