타임라인 클리어 함수 설명
timeline_clear
함수는 특정 타임라인의 "모멘트"를 지우는 기능을 제공합니다. 이 함수는 해당 타임라인의 모든 코드와 액션을 제거하고 빈 상태로 만듭니다.
문법
timeline_clear(ind);
인수
인수 | 타입 | 설명 |
---|---|---|
ind | Timeline Asset | 지울 타임라인의 인덱스 |
반환값
- N/A
예제
if (timeline_position > 200) {
timeline_clear(global.tl);
timeline_index = -1;
}
위의 코드는 특정 모멘트를 지나쳤을 때, 변수 "global.tl"로 지정된 타임라인의 모든 모멘트를 지웁니다.
활용 예제
예제 1: 특정 조건에서 타임라인 클리어
if (player_health <= 0) {
timeline_clear(global.game_over_timeline);
timeline_index = -1;
}
이 코드는 플레이어의 체력이 0 이하일 때 게임 오버 타임라인을 클리어합니다.
예제 2: 이벤트 발생 시 타임라인 클리어
if (event_occurred) {
timeline_clear(global.event_timeline);
timeline_index = -1;
}
이 코드는 특정 이벤트가 발생했을 때 관련 타임라인을 클리어합니다.
예제 3: 레벨 완료 시 타임라인 클리어
if (level_completed) {
timeline_clear(global.level_timeline);
timeline_index = -1;
}
이 코드는 레벨이 완료되었을 때 해당 레벨의 타임라인을 클리어합니다.
예제 4: 사용자 입력에 따라 타임라인 클리어
if (keyboard_check_pressed(vk_space)) {
timeline_clear(global.input_timeline);
timeline_index = -1;
}
이 코드는 사용자가 스페이스 키를 눌렀을 때 입력 관련 타임라인을 클리어합니다.
예제 5: 특정 시간 경과 후 타임라인 클리어
if (current_time > 5000) {
timeline_clear(global.timer_timeline);
timeline_index = -1;
}
이 코드는 현재 시간이 5000ms를 초과했을 때 타이머 타임라인을 클리어합니다.