시간 소스 단위 가져오기
이 문서는 time_source_get_units
함수에 대해 설명합니다. 이 함수는 주어진 시간 소스에 대한 단위를 반환합니다. 시간 소스의 주기 값은 이러한 단위로 표현됩니다.
함수 구문
time_source_get_units(id);
매개변수 설명
매개변수 | 유형 | 설명 |
---|---|---|
id | Time Source ID | 단위를 가져올 시간 소스의 ID |
반환 값
- 시간 소스 단위 상수: 함수는 지정된 시간 소스에 대한 단위를 반환합니다.
활용 예제
예제 1: 기본 사용법
var my_time_source = time_source_create();
var units = time_source_get_units(my_time_source);
예제 2: 여러 시간 소스의 단위 가져오기
var time_source_1 = time_source_create();
var time_source_2 = time_source_create();
var units_1 = time_source_get_units(time_source_1);
var units_2 = time_source_get_units(time_source_2);
예제 3: 단위에 따른 조건 처리
var my_time_source = time_source_create();
var units = time_source_get_units(my_time_source);
if (units == TIME_SOURCE_UNIT_SECONDS) {
// 초 단위일 때의 처리
} else if (units == TIME_SOURCE_UNIT_MILLISECONDS) {
// 밀리초 단위일 때의 처리
}
예제 4: 시간 소스의 주기 값 설정
var my_time_source = time_source_create();
var units = time_source_get_units(my_time_source);
time_source_set_period(my_time_source, 100, units);
이 문서에서는 time_source_get_units
함수의 사용법과 다양한 활용 예제를 소개했습니다.