void AMapleStoryCharacter::Sword()
{
Swording = true;
GetWorldTimerManager().SetTimer(TimerHandle, this, &AMapleStoryCharacter::AtkSword, 2.0f, true);
Swording = false;
}
void AMapleStoryCharacter::AtkSword()
{
GetSprite()->SetFlipbook(AttackAnimation);
//GetWorld()->GetTimerManager().ClearTimer(TimerHandle);
}
为什么这样子写按j的时候角色并没有攻击
GetWorldTimerManager().SetTimer(TimerHandle, this, &AMapleStoryCharacter::AtkSword, 2.0f, true); 这句话我在tick里面放过,在beginplay里面放过,可是好像都没有效果
我是想让他攻击的时候delay个几秒,让攻击动画放完
P.S:我做的是一个2d游戏
仅供参考:
#pragma comment(lib,"user32")
#include <stdio.h>
#include <time.h>
#include <sys/timeb.h>
#include <windows.h>
CRITICAL_SECTION cs_log;
char datestr[16];
char timestr[16];
char mss[4];
void log(char *s) {
struct tm *now;
struct timeb tb;
EnterCriticalSection(&cs_log);
ftime(&tb);
now=localtime(&tb.time);
sprintf(datestr,"%04d-%02d-%02d",now->tm_year+1900,now->tm_mon+1,now->tm_mday);
sprintf(timestr,"%02d:%02d:%02d",now->tm_hour ,now->tm_min ,now->tm_sec );
sprintf(mss,"%03d",tb.millitm);
printf("%s %s.%s %s",datestr,timestr,mss,s);
LeaveCriticalSection(&cs_log);
}
VOID CALLBACK myTimerProc1(
HWND hwnd, // handle of window for timer messages
UINT uMsg, // WM_TIMER message
UINT idEvent, // timer identifier
DWORD dwTime // current system time
) {
log("In myTimerProc1\n");
}
VOID CALLBACK myTimerProc2(
HWND hwnd, // handle of window for timer messages
UINT uMsg, // WM_TIMER message
UINT idEvent, // timer identifier
DWORD dwTime // current system time
) {
log("In myTimerProc2\n");
}
int main() {
int i;
MSG msg;
InitializeCriticalSection(&cs_log);
SetTimer(NULL,0,1000,myTimerProc1);
SetTimer(NULL,0,2000,myTimerProc2);
for (i=0;i<20;i++) {
Sleep(500);
log("In main\n");
if (GetMessage(&msg,NULL,0,0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
DeleteCriticalSection(&cs_log);
return 0;
}
//2018-04-17 10:07:54.218 In main
//2018-04-17 10:07:54.718 In myTimerProc1
//2018-04-17 10:07:55.218 In main
//2018-04-17 10:07:55.718 In myTimerProc2
//2018-04-17 10:07:56.218 In main
//2018-04-17 10:07:56.218 In myTimerProc1
//2018-04-17 10:07:56.718 In main
//2018-04-17 10:07:56.718 In myTimerProc1
//2018-04-17 10:07:57.218 In main
//2018-04-17 10:07:57.718 In myTimerProc2
//2018-04-17 10:07:58.218 In main
//2018-04-17 10:07:58.218 In myTimerProc1
//2018-04-17 10:07:58.718 In main
//2018-04-17 10:07:58.718 In myTimerProc1
//2018-04-17 10:07:59.218 In main
//2018-04-17 10:07:59.718 In myTimerProc2
//2018-04-17 10:08:00.218 In main
//2018-04-17 10:08:00.218 In myTimerProc1
//2018-04-17 10:08:00.718 In main
//2018-04-17 10:08:00.718 In myTimerProc1
//2018-04-17 10:08:01.218 In main
//2018-04-17 10:08:01.718 In myTimerProc2
//2018-04-17 10:08:02.218 In main
//2018-04-17 10:08:02.218 In myTimerProc1
//2018-04-17 10:08:02.718 In main
//2018-04-17 10:08:02.718 In myTimerProc1
//2018-04-17 10:08:03.218 In main
//2018-04-17 10:08:03.718 In myTimerProc2
//2018-04-17 10:08:04.218 In main
//2018-04-17 10:08:04.218 In myTimerProc1
//2018-04-17 10:08:04.718 In main
//2018-04-17 10:08:04.718 In myTimerProc1
//2018-04-17 10:08:05.218 In main
//2018-04-17 10:08:05.718 In myTimerProc2
//2018-04-17 10:08:06.218 In main
//2018-04-17 10:08:06.218 In myTimerProc1
//2018-04-17 10:08:06.718 In main
//2018-04-17 10:08:06.718 In myTimerProc1
//2018-04-17 10:08:07.218 In main
//2018-04-17 10:08:07.718 In myTimerProc2