我做了一个实现简单的动画功能,但是只支持按下后放开,按这不放的时候要停顿5秒左右才能连续播放动画;怎么实现按下后不要停顿能连续播放?
- C/C++ code
/*回调函数*/static void draw_boy(timer * pMe){IDISPLAY_ClearScreen(pMe->a.m_pIDisplay); switch(pMe->wParam) { case AVK_UP: IIMAGE_SetParm(pMe->LPBoy_up_down,IPARM_OFFSET,0,(pMe->pi.cy/14)*(13 - (pMe->boy_infor.boy_up) )); IIMAGE_SetDrawSize(pMe->LPBoy_up_down,22,pMe->pi.cy/14); IIMAGE_Draw(pMe->LPBoy_up_down,pMe->boy_infor.x,pMe->boy_infor.y); //IBASE_Release((IBase *)pMe->LPBoy); break; case AVK_DOWN: IIMAGE_SetParm(pMe->LPBoy_up_down,IPARM_OFFSET,0,(pMe->pi.cy/14)*(6 - (pMe->boy_infor.boy_down) )); IIMAGE_SetDrawSize(pMe->LPBoy_up_down,22,pMe->pi.cy/14); IIMAGE_Draw(pMe->LPBoy_up_down,pMe->boy_infor.x,pMe->boy_infor.y); //IBASE_Release((IBase *)pMe->LPBoy); break;default: return ;}IDISPLAY_Update(pMe->a.m_pIDisplay);}static boolean timer_HandleEvent(timer* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam){ switch (eCode) {case EVT_KEY:switch(wParam) { case AVK_UP: pMe->boy_infor.y -=3; pMe->boy_infor.boy_up++; pMe->boy_infor.boy_up = pMe->boy_infor.boy_up%3; if (SUCCESS != ISHELL_SetTimer(pMe->a.m_pIShell,100,(PFNNOTIFY)draw_boy,pMe)) { return FALSE; } break;case AVK_DOWN: pMe->boy_infor.y +=3; pMe->boy_infor.boy_down++; pMe->boy_infor.boy_down = pMe->boy_infor.boy_down%3; if (SUCCESS != ISHELL_SetTimer(pMe->a.m_pIShell,100,(PFNNOTIFY)draw_boy,pMe)) { return FALSE; } break; default: return FALSE; } return(TRUE);default: break; } return FALSE;}
只上传了上、下键的代码,左、右键代码基本一样,帮看下怎么实现按下不放的连续播放?
------解决方案--------------------------------------------------------
draw_boy()中再起定时器来播放动画,检测按键抬起的事件去消除draw_boy()中启动的定时器。