⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transition.cpp

📁 冰人引擎,本2d游戏引擎定位于游戏次中层引擎。他不像CDX等引擎那样
💻 CPP
字号:
#include "stdafx.h"
#include "ImageX.h"
#include "Transition.h"

//调用方式:把p_FileA设置为黑色背景图

CTransition::CTransition(char* p_FileA)
{
	m_pImageXA=NULL;
	SetImageX(p_FileA);
}	

HRESULT CTransition::SetImageX(char* p_FileA)
{
	if( NULL!=m_pImageXA )
	{
		Free();
	}
	
	m_pImageXA=new CImageX(p_FileA);

	return S_OK;
}

void CTransition::Free(void)
{
	if( NULL!=m_pImageXA )
	{
		delete m_pImageXA;
		m_pImageXA=NULL;
	}
}

void CTransition::FadeIn(long FadeSpeed) 
{
	if(NULL==m_pImageXA)
	{
		return;
	}

	RECT Rect_Screen;    //设置RECT
	Rect_Screen.bottom=CDisplay::Instance()->GetScreenHeight();
	Rect_Screen.right=CDisplay::Instance()->GetScreenWidth();
	Rect_Screen.top=Rect_Screen.left=0;
	
	m_pImageXA->SetRect(&Rect_Screen);

	for( int i=0; i<=4; i++ )
	{
		long old_clock, new_clock;
		new_clock = old_clock = GetTickCount();

		while( new_clock < old_clock + (FadeSpeed+i*6) )
		{
			new_clock = GetTickCount( );
		}
		
		m_pImageXA->DrawAlpha(0,0,false,DRAW_ALPHA_QUALITY,i*60);
		CDisplay::Instance()->UpdataDisplay();
	}
}

void CTransition::FadeOut(long FadeSpeed)
{
	if( NULL==m_pImageXA )
	{
		return;
	}

	RECT Rect_Screen;    //设置RECT
	Rect_Screen.bottom=CDisplay::Instance()->GetScreenHeight();
	Rect_Screen.right=CDisplay::Instance()->GetScreenWidth();
	Rect_Screen.top=Rect_Screen.left=0;
	m_pImageXA->SetRect(&Rect_Screen);

	for( int i=0; i<=4; i++ )
	{
		long old_clock, new_clock;
		new_clock = old_clock = GetTickCount();
		
		while( new_clock < old_clock + (FadeSpeed+i*6) )
		{
			new_clock = GetTickCount( );
		}
		
		m_pImageXA->DrawAlpha(0,0,false,DRAW_ALPHA_QUALITY,255-i*60);
		CDisplay::Instance()->UpdataDisplay();  //更新
	}
}

void CTransition::WindEff(int Size,int WindSpeed)
{
	int step=10;
	
	if( NULL!=m_pImageXA )
	{	
		RECT Rect_Wind={0,0,0,0};
		m_pImageXA->SetRect(&Rect_Wind);  //设置RECT
		
		int col=CDisplay::Instance()->GetScreenHeight()/Size;
		for(int i=1;i<=step;i++)
		{
			Rect_Wind.top=Rect_Wind.left=0;
			Rect_Wind.right=CDisplay::Instance()->GetScreenWidth();
			Rect_Wind.bottom=i*(Size/step);
			m_pImageXA->SetRect(&Rect_Wind);  //设置RECT

			for(int group=0;group<col;group++)
			{
				m_pImageXA->Draw(0,Size*group);
			}

			CDisplay::Instance()->UpdataDisplay();//更新
			
			long old_clock, new_clock;
			new_clock = old_clock = GetTickCount();
			while( new_clock < old_clock + (WindSpeed+i*6) )
			{
				new_clock = GetTickCount( );
			}
		}
	}
}

void CTransition::BoxEff(int Size,int BoxSpeed)
{
	int step=10;
	
	if( NULL!=m_pImageXA )
	{	
		RECT Rect_Wind={0,0,0,0};
		m_pImageXA->SetRect(&Rect_Wind);  //设置RECT
		
		int col=CDisplay::Instance()->GetScreenHeight()/Size;
		int row=CDisplay::Instance()->GetScreenWidth()/Size;
		
		for(int i=1;i<=step;i++)
		{
			Rect_Wind.top=Rect_Wind.left=0;
			Rect_Wind.right=Size;
			Rect_Wind.bottom=i*(Size/step);
			m_pImageXA->SetRect(&Rect_Wind);  //设置RECT
			
			for(int y=0; y<col; y+=2)
			{
				for(int x=0; x<row; x+=2)
				{	
					m_pImageXA->Draw(Size*(x+y%2),Size*y);
				}
			}
			
			CDisplay::Instance()->UpdataDisplay();//更新
			
			long old_clock, new_clock;
			new_clock = old_clock = GetTickCount();
			while( new_clock < old_clock + (BoxSpeed+i*6) )
			{
				new_clock = GetTickCount( );
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -