dbg_sprite_button 함수 설명
dbg_sprite_button 함수는 현재 디버그 섹션 내에서 스프라이트의 일부를 사용하는 버튼 컨트롤을 생성합니다. 버튼을 클릭하면 지정된 함수가 실행됩니다. 현재 디버그 섹션은 dbg_section을 사용하여 마지막으로 생성된 섹션입니다. 이 컨트롤은 두 개의 열로 나뉘지 않고 단일 열로 표시됩니다.
문법
dbg_sprite_button(ref, ref_sprite, ref_sprite_index[, width, height, xoffset, yoffset, width_sprite, height_sprite]);
매개변수 설명
| 매개변수 | 유형 | 설명 |
|---|---|---|
| ref | Reference or Script Function or Function | 버튼 클릭 시 호출할 함수 또는 함수에 대한 참조입니다. |
| ref_sprite | Reference | 버튼에 사용할 스프라이트 자산을 보유하는 변수에 대한 참조입니다. |
| ref_sprite_index | Reference | 사용할 스프라이트 서브 이미지의 인덱스를 보유하는 변수에 대한 참조입니다. |
| width | Real | 버튼의 너비(픽셀). 기본값은 스프라이트의 너비입니다. |
| height | Real | 버튼의 높이(픽셀). 기본값은 스프라이트의 높이입니다. |
| xoffset | Real | 스프라이트의 x 오프셋. 기본값은 0입니다. |
| yoffset | Real | 스프라이트의 y 오프셋. 기본값은 0입니다. |
| width_sprite | Real | 스프라이트의 너비(픽셀). 기본값은 스프라이트의 너비입니다. |
| height_sprite | Real | 스프라이트의 높이(픽셀). 기본값은 스프라이트의 높이입니다. |
반환값
N/A
활용 예제
예제 1: 기본 사용법
sprite = sprite_index;
image = image_index;
ref_to_sprite = ref_create(self, "sprite");
ref_to_image = ref_create(self, "image");
toggle = function(){
image = (image == 0) ? 1 : 0;
};
dbg_sprite_button(toggle, ref_to_sprite, ref_to_image);
show_debug_overlay(true);
위 코드는 버튼을 설정하여 클릭할 때 스프라이트 서브 이미지를 전환하는 방법을 보여줍니다. 현재 객체 인스턴스의 sprite_index와 image_index를 인스턴스 변수 sprite와 image에 할당합니다. sprite에 대한 참조를 생성하고 ref_to_sprite에 저장하며, image에 대한 참조를 ref_to_image에 저장합니다. 그런 다음 image의 값을 변경하는 메서드 toggle를 정의합니다. 마지막으로 dbg_sprite_button을 사용하여 버튼을 추가하고 show_debug_overlay를 호출하여 디버그 오버레이를 표시합니다.
예제 2: 선택적 매개변수 사용
sprite = sprite_index;
image = image_index;
msg = function(){
show_debug_message("Clicked the button!");
}
ref_to_sprite = ref_create(self, "sprite");
ref_to_image = ref_create(self, "image");
ref_to_msg = ref_create(self, "msg");
dbg_sprite_button(ref_to_msg, ref_to_sprite, ref_to_image, 100, 100, sprite_width/2, sprite_height/2, sprite_width/4, sprite_height/4);
show_debug_overlay(true);
위 코드는 선택적 매개변수를 사용하여 버튼에 스프라이트의 일부만 사용하는 방법을 보여줍니다. 먼저 sprite_index와 image_index를 두 개의 인스턴스 변수에 할당하고, 간단한 메서드를 생성하여 msg 변수에 할당합니다. 그런 다음 ref_create를 사용하여 각 변수에 대한 참조를 생성하고 dbg_sprite_button을 호출하여 버튼을 추가합니다. 버튼의 크기는 100x100 픽셀이며, 스프라이트의 중앙에서 시작하여 지정된 부분을 버튼 전체에 그립니다. 마지막으로 show_debug_overlay를 호출하여 디버그 오버레이를 표시합니다.