hgeAnimation使用详解

#include<hge.h>
#include<hgefont.h>
#include<hgesprite.h>
#include<hgeanim.h>
 
HGE *hge=0;


HTEXTURE tex;


hgeAnimation *ani;


HEFFECT snd;


float dt=16;


int x;


float x1=0.0f;


float y1=128.0f;


float time;


float FPS=0;


void boom()
{
hge->Effect_Play(snd);
}


bool FrameFunc()
{
if (x1>200)
{
x1+=0.1;
y1+=0.043;


}
else
{
x1+=0.1;

}


time=hge->Timer_GetTime();
ani->SetTexture(tex);//这句加不加都行
//spt->GetFlip(true,false); 
//ani->SetMode(HGEANIM_FWD);//设置回放模式。 


ani->SetFrame(x); //设置当前动画的帧。 
ani->SetFrames(8); //设置所有的动画帧。


if (time>FPS)
{
FPS=1/dt+time;
x++;
ani->Update(FPS);
}


return false;


}


bool RenderFunc()
{


hge->Gfx_BeginScene();
hge->Gfx_Clear(0);

if(x1>200)
{
ani->RenderEx(x1,y1,0.4);
}else
{
ani->Render(x1,0+128);
}
ani->Play();
hge->Gfx_EndScene();
return false;
}
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
{
hge=hgeCreate(HGE_VERSION);
hge->System_SetState(HGE_FRAMEFUNC,FrameFunc);
hge->System_SetState(HGE_RENDERFUNC,RenderFunc);
hge->System_SetState(HGE_TITLE,"Animationtemp2");
hge->System_SetState(HGE_WINDOWED,true);
hge->System_SetState(HGE_USESOUND,false);
hge->System_SetState(HGE_SCREENBPP,32);
hge->System_SetState(HGE_SCREENWIDTH,800);
hge->System_SetState(HGE_SCREENHEIGHT,600);


if(hge->System_Initiate())
{
tex=hge->Texture_Load("e:\\resource\\denglongyu.png");

ani=new hgeAnimation(tex,8,1,0,0,1536/3,1024/4);


ani->SetHotSpot(256,128);


hge->System_Start();
}
else
{
MessageBox(NULL,hge->System_GetErrorMessage(),"Error",MB_OK);
}


hge->System_Shutdown();
hge->Release();

}


看看效果图:

hgeAnimation使用详解_第1张图片

你可能感兴趣的:(hge引擎编程)