1:
2: // 5o fps 1f = 0.02s
3: #define DEFAULT_COUNT 4
4: #define DEFAULT_STOP 10
5: struct WindowAni
6: {
7:
8: WindowAni()
9: {
10: mCount = DEFAULT_COUNT;
11: mCountStop = DEFAULT_STOP; // 停留时间(step)
12: mCurCount = 0;
13: mWindow = NULL;
14: }
15:
16: int mCount; // 10
17: int mCountStop; // 停留 2
18: int mCurCount; // current step
19: //---------------------------
20: float mXBegin;
21: float mYBegin;
22:
23: float mXEnd;
24: float mYEnd;
25:
26: Timer * timer;
27: CEGUI::Window * mWindow;
28: //--------------------------------------------------------
29:
30: void SetImage(string nameImag)
31: {
32: mWindow->setProperty("Image",nameImag.c_str());
33: }
34:
35:
36: /** @param
37: Timer - 所需的计时器
38: Window - 要移动的窗口
39: float,float,float,float - 窗口的起点和终点
40: int _count - 到达终点所需的step
41: int _count_stop - 到达终点时,停留的step step-是在timer中定义的
42: string image - 所显示的窗口具体呈现
43: */
44: void Begin(Timer* _timer,Window *wnd,float _xBegin,float _yBegin,float _xEnd, float _yEnd,int _count,int _count_stop,string _imageset)
45: {
46:
47: mCurCount = 0;
48: mWindow = wnd;
49: mWindow->setAlwaysOnTop(true);
50: timer = _timer;
51: SetImage(_imageset);
52: mXBegin = _xBegin;
53: mXEnd = _xEnd;
54: mYBegin = _yBegin;
55: mYEnd = _yEnd;
56:
57: mCount = _count;
58: mCountStop = _count_stop;
59:
60: mWindow->show();
61: mWindow->setPosition(UVector2(UDim(0,mXBegin),UDim(0,mYBegin)));
62: timer->start();
63: }
64:
65: bool Move()
66: {
67: mCurCount ++;
68: if(mCurCount >= (mCount + mCountStop))
69: {
70: mWindow->hide();
71: timer->stop();
72: SkrGamePtr->UnlockMsg();
73: return true;
74: }
75:
76: if(mCurCount > mCount)
77: {
78: mWindow->setPosition(UVector2(UDim(0,mXEnd),UDim(0,mYEnd)));
79: return false;
80: }
81: float xStep = (mXEnd - mXBegin) / (float)mCount;
82: float yStep = (mYEnd - mYBegin) / (float)mCount;
83: float xNew = mXBegin + xStep * mCurCount;
84: float yNew = mYBegin + yStep * mCurCount;
85: mWindow->setPosition(UVector2(UDim(0,xNew),UDim(0,yNew)));
86: return false;
87: }
88:
89: bool MoveII()
90: {
91: mCurCount ++;
92: if(mCurCount >= (mCount + mCountStop))
93: {
94: mWindow->hide();
95: timer->stop();
96: SkrGamePtr->UnlockMsg();
97: return true;
98: }
99:
100: // 如果小于,就呆在那
101: if(mCurCount < mCountStop)
102: {
103: return false ;
104: }
105:
106: if(mCurCount > mCount + mCountStop)
107: {
108: mWindow->setPosition(UVector2(UDim(0,mXEnd),UDim(0,mYEnd)));
109: return false;
110: }
111: float xStep = (mXEnd - mXBegin) / (float)mCount;
112: float yStep = (mYEnd - mYBegin) / (float)mCount;
113: float xNew = mXBegin + xStep * (mCurCount - mCountStop);
114: float yNew = mYBegin + yStep * (mCurCount - mCountStop);
115: mWindow->setPosition(UVector2(UDim(0,xNew),UDim(0,yNew)));
116: return false;
117: }
118: };
119:
120: