今天我遇到了GameMakers切換語句正在執行的主要問題。當執行HTTP ASYNC EVENT時,show_message(answer);被執行,但它下面的switch語句沒有。我認爲這是一個編譯器錯誤,因爲它似乎是「答案變量」的string_length是1,並且使用string_digits來確保它逃避所有可能出現的空格或不必要的字符,這些字符可能在檢索http回調時出現。可變答案的 唯一可能返回的值是:0,1,2,3,4,GameMaker:Studio切換語句不會在http異步事件中執行
因此,這裏是HTTP ASYNC事件的代碼:
if(ds_map_find_value(async_load, "id") == request_auth) {
if(ds_map_find_value(async_load, "status") == 0) {
callback = ds_map_find_value(async_load, "result");
var answer = string_digits(callback);
show_message(answer);
switch(answer) {
case USERNAME_EXISTS:
show_message("username already exists");
break;
case ACCOUNT_CREATED:
show_message("Your account has been successfully created!");
break;
case LOGGED_IN:
buffer_seek(global.buffer, buffer_seek_start, 0);
buffer_write(global.buffer, buffer_u8, 0);
buffer_write(global.buffer, buffer_string, "username");
Send();
break;
case INCORRECT_PASSWORD:
show_message("your password is incorrect");
break;
case INCORRECT_USERNAME:
show_message("your username is invalid");
break;
}
}
else {
callback = noone;
}
}
預先感謝所有解答!乾杯!
宏中的哪些值?它是數字('0','1','2'等)還是字符串('「0」,「1」,「」2「等)? – Dmi7ry