动画问题 [英] Problem with Animation

查看:84
本文介绍了动画问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 您好
已编写 a 代码 执行 动画 使用 Visual Studio 2008 got mountains a road a car car to travel on 道路但是 i 执行 program a 灰色 窗口 慢慢地 捕获 我的 屏幕到期 large size i am 跳过 默认 代码
* view cpp file 是:



  //   AnimationCarView.cpp:CAnimationCarView类的实现 
//



// CAnimationCarView

IMPLEMENT_DYNCREATE(CAnimationCarView,CView)

BEGIN_MESSAGE_MAP(CAnimationCarView ,CView)
// 标准打印命令
ON_COMMAND(ID_FILE_PRINT,& CView :: OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT,& CView :: OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW,& CView :: OnFilePrintPreview)
ON_WM_TIMER()
ON_WM_ERASEBKGND()
ON_WM_CREATE()
END_MESSAGE_MAP()

// CAnimationCarView构造/销毁

CAnimationCarView :: CAnimationCarView()
{
// TODO:在此处添加构造代码
i = 150 ,j = 190 ,k = 145 ,l = 140 ,m = 138 ,n = 195 ,o = 197 ,p = 170 ,q = 148 ,r = 185 ;
penGrey.CreatePen(PS_SOLID, 5 ,RGB( 128 128 128 )); // 灰色
penLGrey.CreatePen(PS_SOLID, 5 ,RGB( 220 220 220 )); // LGREY颜色
penBlack.CreatePen(PS_SOLID, 5 ,RGB( 0 0 0 ));
pOldPen = NULL;
brGrey.CreateSolidBrush(RGB( 128 128 128 ));
brLGrey.CreateSolidBrush(RGB( 220 220 220 ));
brBlack.CreateSolidBrush(RGB( 0 0 0 ));
pOldBrush = NULL;

}




// CAnimationCarView绘图

void CAnimationCarView :: OnDraw(CDC * pDC)
{
CAnimationCarDoc * pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return ;
CBitmap XMap,* pOldMap;
CRect rc;
GetClientRect(& rc);
// pDC-> DPtoLP(rc);
CBrush brBackground( RGB( 255 255 255 ) );
// pDC-> FillRect(rc,& brBackground);
XMap.CreateCompatibleBitmap(pDC,rc.Width(),rc.Height());
CDC WorkDC;
CDC * MyDC =& WorkDC;
MyDC-> CreateCompatibleDC(pDC);
MyDC-> FillRect(rc,& brBackground);
pOldMap = MyDC-> SelectObject(& XMap);
road(MyDC);
mountain(MyDC);
stationary_car(MyDC);
pDC-> BitBlt( 0 0 ,rc.Width(),rc。高度(),MyDC, 0 0 ,SRCCOPY);
MyDC-> SelectObject(pOldMap);

XMap.DeleteObject();
MyDC-> DeleteDC();

// TODO:在此处添加原生数据的绘图代码
}

void CAnimationCarView :: mountain(CDC * pDC)
{
// setcolor(BROWN);
CPen penBrown(PS_SOLID, 5 ,RGB( 150 75 0 ));
CPen * pOldPen = NULL;
pOldPen = pDC-> SelectObject(& penBrown);
// line(0,250,700,250);
pDC-> MoveTo(< span class =code-digit> 0
250 );
pDC-> LineTo( 700 250 );
// line(0,250,0,160);
pDC-> MoveTo ( 0 250 );
pDC-> LineTo( 0 160 );
// line(0,160,30,200);
pDC-> MoveTo ( 0 160 );
pDC-> LineTo( 30 200 );
// line(30,200,80,120);
pDC-> MoveTo ( 30 200 );
pDC-> LineTo( 80 120 );
// arc(90,124,30,150,10);
pDC-> ; AngleArc( 90 124 10 30 150 );
// line(99,119,150,180);
pDC-> MoveTo(< span class =code-digit> 99
119 );
pDC-> LineTo( 150 180 );
// line(150,180,220,100);
pDC-> MoveTo(< span class =code-digit> 150
180 );
pDC-> LineTo( 220 100 );
// arc(234,106,30,150,15);
pDC-> ; AngleArc( 234 106 15 30 150 );
// line(248,99,320,200);
pDC-> MoveTo ( 248 99 );
pDC-> LineTo( 320 200 );
// line(320,200,370,125);
pDC-> MoveTo(< span class =code-digit> 320
200 );
pDC-> LineTo( 370 125 );
// arc(380,129,30,150,10);
pDC-> ; AngleArc( 380 129 10 30 150 );
// line(389,124,430,180);
pDC-> MoveTo(< span class =code-digit> 389
124 );
pDC-> LineTo( 430 180 );
// line(430,180,505,90);
pDC-> MoveTo ( 430 180 );
pDC-> LineTo( 505 90 );
// arc(519,96,30,150,15);
pDC - > AngleArc( 519 96 15 30 150 );
// line(533,89,605,200);
pDC-> MoveTo ( 533 89 );
pDC-> LineTo( 605 200 );
// line(605,200,700,110);
pDC-> MoveTo(< span class =code-digit> 605 , 200 );
pDC-> LineTo( 700 170 );
// line(700,170,700,250);
pDC-> MoveTo(< span class =code-digit> 700 , 170 );
pDC-> LineTo( 700 250 );
CBrush brBrown(RGB( 150 75 0 ));
CBrush * pOldBrush = NULL;
pOldBrush = pDC-> SelectObject(& brBrown);
pDC-> FloodFill( 10 245 ,RGB( 150 75 0 ));
pDC-> SelectObject(pOldBrush);
pDC-> SelectObject(pOldPen);

}

void CAnimationCarView :: road(CDC * pDC){
CPoint poly6 [< span class =code-digit> 8
] = {CPoint( 0 400 ),CPoint( 210 400 ),CPoint( 210 440 ),CPoint( 0 440 )};
CPen笔(PS_SOLID, 5 ,RGB( 220 220 220 ));
CPen * pOldPen = NULL;
pOldPen = pDC-> SelectObject(& pen);
CBrush br(RGB( 220 220 220 ));
CBrush * pOldBrush = NULL;
pOldBrush = pDC-> SelectObject(& br);
pDC->多边形(poly6, 4 );
pDC-> SelectObject(pOldBrush);
pDC-> SelectObject(pOldPen);
}


void CAnimationCarView :: stationary_car(CDC * pDC)
{
// int i = 150,j = 190,k = 145,l = 140,m = 138,n = 195 ,o = 197,p = 170,q = 148,r = 185;
// CPen penGrey(PS_SOLID,5,RGB(128,128,128)); //灰色
CBitmap XMap,* pOldMap;
CPen * pOldPen = NULL;
pOldPen = pDC-> SelectObject(& penGrey);
SIZE尺寸;
Size.cx = GetSystemMetrics(SM_CXSCREEN);
Size.cy = GetSystemMetrics(SM_CYSCREEN);
XMap.CreateCompatibleBitmap(pDC,Size.cx,Size.cy);
CDC WorkDC;
CDC * MyDC =& WorkDC;
MyDC-> CreateCompatibleDC(pDC);
pOldMap = MyDC-> SelectObject(& XMap);
// line(i,402,j,402);
MyDC - > MoveTo(i, 402 );
MyDC-> LineTo(j, 402 );
// line(j,415,k,415);
MyDC - > MoveTo(j, 415 );
MyDC-> LineTo(k, 415 );
// line(j,402,j,415);
MyDC - > MoveTo(j, 402 );
MyDC-> LineTo(j, 415 );
// line(k,415,i,402);
MyDC - > MoveTo(k, 415 );
MyDC-> LineTo(i, 402 );
// setfillstyle(SOLID_FILL,6);
// CBrush brGrey(RGB(128,128,128));
CBrush * pOldBrush = NULL;
// floodfill(p,408,6);
// 注意如果在选择对象之后完成FloodFill,则会发生颜色混合
pOldBrush = MyDC-> SelectObject (安培; brGrey);
MyDC-> FloodFill(p, 408 ,RGB( 128 128 128 ));
// line(n,415,o,428);
MyDC - > MoveTo(n, 415 );
MyDC-> LineTo(o, 428 );
// line(l,415,m,428);
MyDC - > MoveTo(l, 415 );
MyDC-> LineTo(m, 428 );
// line(l,415,n,415);
MyDC - > MoveTo(l, 415 );
MyDC-> LineTo(n, 415 );
// line(o,428,m,428);
MyDC - > MoveTo(o, 428 );
MyDC-> LineTo(m, 428 );
// setfillstyle(SOLID_FILL,6);
// floodfill(p,422,6);
MyDC-> FloodFill(p, 422 ,RGB( 128 128 128 ));
MyDC-> SelectObject(pOldBrush);
MyDC-> SelectObject(pOldPen);
// 绘图轮
// circle(q,434,5);
CBrush brBlack(RGB( 0 0 0 ));
pOldBrush = NULL;
pOldBrush = MyDC-> SelectObject(& brBlack);
// CPen penBlack(PS_SOLID,5,RGB(0,0,0)); //黑色颜色
pOldPen = NULL;
pOldPen = MyDC-> SelectObject(& penBlack);
MyDC-> MoveTo(r, 434 );
MyDC-> AngleArc(q, 434 5 0 360 );
MyDC-> FloodFill(q, 434 ,RGB( 0 0 0 ));
// circle(r,434,5);
MyDC-> ; AngleArc(r, 434 5 0 360 );
pDC-> BitBlt(j,k,Size.cx,Size.cy,MyDC, 0 0 ,SRCCOPY);
MyDC-> SelectObject(pOldPen);
MyDC-> SelectObject(pOldBrush);
MyDC-> SelectObject(pOldMap);
XMap.DeleteObject();
MyDC-> DeleteDC();

}











// CAnimationCarView消息处理程序

void CAnimationCarView :: OnTimer(UINT_PTR nIDEvent)
{
// TODO:在此处添加您的消息处理程序代码和/或调用默认
如果(i> 0){
i = i- 3 ;
Invalidate();
j = j- 3 ; k = k- 3 ; l = l- 3 ; m = m- 3 ; n = n- 3 ; o = o- 3 ; p = p- 3 ; q = q- 3 ; r = r- 3 ;
}
CView :: OnTimer(nIDEvent);
}

BOOL CAnimationCarView :: OnEraseBkgnd(CDC * pDC)
{
// TODO:在此处添加消息处理程序代码和/或调用默认值
return TRUE;
return CView :: OnEraseBkgnd(pDC);
}

int CAnimationCarView :: OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView :: OnCreate(lpCreateStruct)== - 1
return - 1 ;
SetTimer( 1 200 ,NULL);

// TODO:在此处添加专门的创作代码

return 0 ;
}





头文件是:



< pre lang =c ++> // AnimationCarView.h:CAnimationCarView类的接口
//


#pragma一次


class CAnimationCarView: public CView
{
受保护 // 仅从序列化创建
CAnimationCarView();
DECLARE_DYNCREATE(CAnimationCarView)

// 属性
public
CAnimationCarDoc * GetDocument() const ;
int i,j,k,l,m,n,o,p,q,r;
CPen penGrey,penLGrey,penBlack;
CPen * pOldPen;
CBrush brGrey,brLGrey,brBlack;
CBrush * pOldBrush;
// 操作
public
void mountain(CDC *);
void road(CDC *);
void stationary_car(CDC *);
// 覆盖
public
虚拟 void OnDraw(CDC * pDC); // 重写以绘制此视图
虚拟 BOOL PreCreateWindow(CREATESTRUCT& cs);
protected
virtual BOOL OnPreparePrinting(CPrintInfo * pInfo);
virtual void OnBeginPrinting(CDC * pDC,CPrintInfo * pInfo);
虚拟 void OnEndPrinting(CDC * pDC,CPrintInfo * pInfo);

// 实施


// 生成的消息映射函数
protected
DECLARE_MESSAGE_MAP()
public
afx_msg void OnTimer(UINT_PTR nIDEvent);
afx_msg BOOL OnEraseBkgnd(CDC * pDC);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};

#ifndef _DEBUG // AnimationCarView.cpp中的调试版本
inline CAnimationCarDoc * CAnimationCarView :: GetDocument() const
{ return reinterpret_cast< CAnimationCarDoc *> ;(m_pDocument); }
#endif







有人请指导我。



Zulf。

解决方案



我正在使用双缓冲来实现动画。我想给汽车制作动画。

我从另一个论坛收到以下建议

你创建两个相同大小和bitdepth的位图
一个持有活动/可见框架


一个持有你正在处理的新框架

你的OnPaint只会破坏无效的矩形可视位图到屏幕。

当你的新帧结束时,你将指针/手柄翻转到2位图,这样新帧就变成了可见帧,而之前可见的帧现在变成了新的帧位图你将会正在努力。
使整个屏幕无效,OnPaint将完成余下的
重复上述3个步骤,直到达到最终条件。



但我不知道如何实现它。请指导我。



Zulfi。


Hi,
I have written a code to perform animation using Visual Studio 2008. It has got mountains, a road and a car. The car has to travel on the road. But when i execute the program a grey window slowly captures my screen. Due to large size i am skipping the default code.
The *view.cpp file is:


// AnimationCarView.cpp : implementation of the CAnimationCarView class
//



// CAnimationCarView

IMPLEMENT_DYNCREATE(CAnimationCarView, CView)

BEGIN_MESSAGE_MAP(CAnimationCarView, CView)
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)
	ON_WM_TIMER()
	ON_WM_ERASEBKGND()
	ON_WM_CREATE()
END_MESSAGE_MAP()

// CAnimationCarView construction/destruction

CAnimationCarView::CAnimationCarView()
{
	// TODO: add construction code here
    i=150,j=190,k=145,l=140,m=138,n=195,o=197,p=170,q=148,r=185;
	penGrey.CreatePen(PS_SOLID, 5, RGB(128,128,128));//GREY color
	penLGrey.CreatePen(PS_SOLID,5, RGB(220,220,220));//LGREY color
	penBlack.CreatePen(PS_SOLID, 5, RGB(0,0,0));
	pOldPen=NULL;
	brGrey.CreateSolidBrush(RGB(128, 128, 128));
	brLGrey.CreateSolidBrush(RGB(220,220,220));
	brBlack.CreateSolidBrush(RGB(0, 0, 0));
	pOldBrush=NULL;
	
}




// CAnimationCarView drawing

void CAnimationCarView::OnDraw(CDC* pDC)
{
	CAnimationCarDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;
CBitmap XMap,*pOldMap;
	CRect rc;
    GetClientRect(&rc);
	//pDC->DPtoLP( rc );
    CBrush  brBackground( RGB( 255, 255, 255 ) );
    //pDC->FillRect( rc, &brBackground );
	XMap.CreateCompatibleBitmap(pDC,rc.Width(), rc.Height());
	CDC WorkDC;
	CDC *MyDC=&WorkDC;
	MyDC->CreateCompatibleDC(pDC);
	MyDC->FillRect(rc, &brBackground);
	pOldMap=MyDC->SelectObject(&XMap);
	road(MyDC);
	mountain(MyDC);
	stationary_car(MyDC);
	pDC->BitBlt(0, 0, rc.Width(), rc.Height(), MyDC, 0, 0, SRCCOPY);
	MyDC->SelectObject(pOldMap);
	
	XMap.DeleteObject();
	MyDC->DeleteDC();

	// TODO: add draw code for native data here
}

void CAnimationCarView::mountain(CDC* pDC)
{
	//setcolor(BROWN);
	CPen penBrown(PS_SOLID, 5, RGB(150,75,0));
	CPen* pOldPen=NULL;
	pOldPen=pDC->SelectObject(&penBrown);
	//line(0,250,700,250);
	pDC->MoveTo(0,250);
	pDC->LineTo(700,250);
	//line(0,250,0,160);
	pDC->MoveTo(0,250);
	pDC->LineTo(0,160);
	//line(0,160,30,200);
	pDC->MoveTo(0,160);
	pDC->LineTo(30,200);
	//line(30,200,80,120);
	pDC->MoveTo(30,200);
	pDC->LineTo(80,120);
    //arc(90,124,30,150,10);
	pDC->AngleArc(90,124,10,30,150);
	//line(99,119,150,180);
	pDC->MoveTo(99,119);
	pDC->LineTo(150,180);
	//line(150,180,220,100);
	pDC->MoveTo(150,180);
	pDC->LineTo(220,100);
	//arc(234,106,30,150,15);
	pDC->AngleArc(234,106,15,30,150);
	//line(248,99,320,200);
	pDC->MoveTo(248,99);
	pDC->LineTo(320,200);
	//line(320,200,370,125);
	pDC->MoveTo(320,200);
	pDC->LineTo(370,125);
	//arc(380,129,30,150,10);
	pDC->AngleArc(380,129,10,30,150);
	//line(389,124,430,180);
	pDC->MoveTo(389,124);
	pDC->LineTo(430,180);
	//line(430,180,505,90);
	pDC->MoveTo(430,180);
	pDC->LineTo(505,90);
	//arc(519,96,30,150,15);
	pDC->AngleArc(519,96,15,30,150);
	//line(533,89,605,200);
	pDC->MoveTo(533,89);
	pDC->LineTo(605,200);
	//line(605,200,700,110);
	pDC->MoveTo(605,200);
	pDC->LineTo(700,170);
	//line(700,170,700,250);
	pDC->MoveTo(700,170);
	pDC->LineTo(700,250);
	CBrush brBrown(RGB(150, 75, 0));
	CBrush* pOldBrush=NULL;
	pOldBrush=pDC->SelectObject(&brBrown);
	pDC->FloodFill(10,245,RGB(150,75,0));
	pDC->SelectObject(pOldBrush);
	pDC->SelectObject(pOldPen);
	
}

void CAnimationCarView::road(CDC* pDC){ 
	CPoint poly6[8]={CPoint(0,400), CPoint(210,400),CPoint(210,440),CPoint(0,440)};
	CPen pen(PS_SOLID, 5, RGB(220,220,220));
	CPen* pOldPen=NULL;
	pOldPen=pDC->SelectObject(&pen);
	CBrush br(RGB(220, 220, 220));
	CBrush* pOldBrush=NULL;
	pOldBrush=pDC->SelectObject(&br);
	pDC->Polygon(poly6, 4);
	pDC->SelectObject(pOldBrush);
	pDC->SelectObject(pOldPen);
	}


void CAnimationCarView::stationary_car(CDC* pDC)
{
	//int i=150,j=190,k=145,l=140,m=138,n=195,o=197,p=170,q=148,r=185;
	//CPen penGrey(PS_SOLID, 5, RGB(128,128,128));//GREY color
	CBitmap XMap,*pOldMap;
	CPen* pOldPen=NULL;
	pOldPen=pDC->SelectObject(&penGrey);
	SIZE Size;
    Size.cx = GetSystemMetrics(SM_CXSCREEN);
    Size.cy = GetSystemMetrics(SM_CYSCREEN);
	XMap.CreateCompatibleBitmap(pDC,Size.cx,Size.cy);
	CDC WorkDC;
	CDC *MyDC=&WorkDC;
	MyDC->CreateCompatibleDC(pDC);
	pOldMap=MyDC->SelectObject(&XMap);
	//line(i,402,j,402);
	MyDC->MoveTo(i,402);
	MyDC->LineTo(j,402);
	//line(j,415,k,415);
	MyDC->MoveTo(j,415);
	MyDC->LineTo(k,415);
	//line(j,402,j,415);
	MyDC->MoveTo(j,402);
	MyDC->LineTo(j,415);
	//line(k,415,i,402);
	MyDC->MoveTo(k,415);
	MyDC->LineTo(i,402);
	//setfillstyle(SOLID_FILL,6);
	//CBrush brGrey(RGB(128, 128, 128));
	CBrush* pOldBrush=NULL;
	//floodfill(p,408,6);
	//NOTE IF FloodFill done after select object, color mixing would occur 
	pOldBrush=MyDC->SelectObject(&brGrey);
	MyDC->FloodFill(p,408,RGB(128,128,128));
	//line(n,415,o,428);
	MyDC->MoveTo(n,415);
	MyDC->LineTo(o,428);
	//line(l,415,m,428);
	MyDC->MoveTo(l,415);
	MyDC->LineTo(m,428);
	//line(l,415,n,415);
	MyDC->MoveTo(l,415);
	MyDC->LineTo(n,415);
	//line(o,428,m,428);
	MyDC->MoveTo(o,428);
	MyDC->LineTo(m,428);
	//setfillstyle(SOLID_FILL,6);
	//floodfill(p,422,6);
	MyDC->FloodFill(p,422,RGB(128,128,128));
	MyDC->SelectObject(pOldBrush);
	MyDC->SelectObject(pOldPen);
	//Drawing wheels
	//circle(q,434,5);
	CBrush brBlack(RGB(0, 0, 0));
	pOldBrush=NULL;
	pOldBrush=MyDC->SelectObject(&brBlack);
	//CPen penBlack(PS_SOLID, 5, RGB(0,0,0));//Black color
	pOldPen=NULL;
	pOldPen=MyDC->SelectObject(&penBlack);
	MyDC->MoveTo(r,434);
	MyDC->AngleArc(q,434,5,0,360);
	MyDC->FloodFill(q,434,RGB(0,0,0));
	//circle(r,434,5);
	MyDC->AngleArc(r,434,5,0,360);
	pDC->BitBlt(j,k,Size.cx,Size.cy,MyDC,0,0,SRCCOPY);
	MyDC->SelectObject(pOldPen);
	MyDC->SelectObject(pOldBrush);
	MyDC->SelectObject(pOldMap);
	XMap.DeleteObject();
	MyDC->DeleteDC();

}











// CAnimationCarView message handlers

void CAnimationCarView::OnTimer(UINT_PTR nIDEvent)
{
	// TODO: Add your message handler code here and/or call default
    if(i>0){
	i=i-3;
	Invalidate();
	j=j-3;k=k-3;l=l-3;m=m-3;n=n-3;o=o-3;p=p-3;q=q-3;r=r-3;
	}
	CView::OnTimer(nIDEvent);
}

BOOL CAnimationCarView::OnEraseBkgnd(CDC* pDC)
{
	// TODO: Add your message handler code here and/or call default
    return TRUE;
	return CView::OnEraseBkgnd(pDC);
}

int CAnimationCarView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	SetTimer(1,200,NULL);

	// TODO:  Add your specialized creation code here

	return 0;
}



The header file is:

// AnimationCarView.h : interface of the CAnimationCarView class
//


#pragma once


class CAnimationCarView : public CView
{
protected: // create from serialization only
	CAnimationCarView();
	DECLARE_DYNCREATE(CAnimationCarView)

// Attributes
public:
	CAnimationCarDoc* GetDocument() const;
    int i,j,k,l,m,n,o,p,q,r;
   CPen penGrey, penLGrey, penBlack;
   CPen *pOldPen;
    CBrush brGrey, brLGrey, brBlack;
    CBrush* pOldBrush;
// Operations
public:
	void mountain(CDC*);
   void road(CDC*);
   void   stationary_car(CDC*);
// Overrides
public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);

// Implementation


// Generated message map functions
protected:
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};

#ifndef _DEBUG  // debug version in AnimationCarView.cpp
inline CAnimationCarDoc* CAnimationCarView::GetDocument() const
   { return reinterpret_cast<CAnimationCarDoc*>(m_pDocument); }
#endif




Somebody plz guide me.

Zulf.

解决方案

Hi,
I am using double buffering to achieve animation. I want to animate a car.
I have received following advise from one another forum

You create two bitmaps of the same size and bitdepth
one holds the active/visible frame


one holds the new frame you're working on

your OnPaint only blits the invalidated rect from the visible bitmap to the screen.

When your new frame is finished, you flip the pointers/handles to the 2 bitmaps so the "new frame" becomes the visible frame, and the previously visible frame now becomes the new frame bitmap you'll be working on.
Invalidate the entire screen, OnPaint will do the rest
Repeat above 3 steps until whatever end condition is reached.


but i dont know how to implement it. Kindly guide me.

Zulfi.


这篇关于动画问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆