current_month 변수 설명
current_month
는 현재 월을 숫자로 반환하는 읽기 전용 변수입니다. 여기서 1은 1월, 12는 12월을 의미합니다.
문법
current_month;
반환값
- 현재 월을 숫자로 반환합니다.
예제
아래 코드는 현재 날짜를 화면에 표시합니다. 날짜는 "오늘은 [일]/[월]/[년]" 형식으로 출력됩니다.
draw_text((32, 32), "Today is " + string(current_day) + "/" + string(current_month) + "/" + string(current_year) + ".");
활용 예제
예제 번호 | 설명 | 코드 스니펫 |
---|---|---|
1 | 현재 월을 출력하기 | ```gml |
var month = current_month; | ||
show_message("현재 월은 " + string(month) + "입니다."); | ||
``` | ||
2 | 월에 따라 다른 메시지 출력 | ```gml |
if (current_month == 12) { | ||
show_message("메리 크리스마스!"); | ||
} else { | ||
show_message("현재 월은 " + string(current_month) + "입니다."); | ||
} | ||
``` | ||
3 | 월별 이벤트 처리 | ```gml |
switch (current_month) { | ||
case 1: | ||
// 1월 이벤트 코드 | ||
break; | ||
case 2: | ||
// 2월 이벤트 코드 | ||
break; | ||
// 다른 월 처리 코드 | ||
} | ||
``` |
이와 같이 current_month
변수를 활용하여 다양한 기능을 구현할 수 있습니다.