Flex Panel Node Aspect Ratio 가져오기
이 문서는 Flex Panel Node의 비율(aspect ratio)을 가져오는 함수에 대해 설명합니다. 이 함수는 주어진 Flex Panel Node의 aspectRatio 속성을 반환합니다.
함수 설명
함수 이름
flexpanel_node_style_get_aspect_ratio
문법
flexpanel_node_style_get_aspect_ratio(node);
매개변수
매개변수 | 타입 | 설명 |
---|---|---|
node | Flex Panel Node | 읽어올 노드 |
반환값
- Real: 노드의 비율(aspect ratio)을 반환합니다.
예제
var _aspect = flexpanel_node_style_get_aspect_ratio(_node);
위 코드는 노드의 비율을 가져와서 로컬 변수에 저장합니다.
활용 예제
예제 1: 비율 확인 후 스타일 변경
var _aspect = flexpanel_node_style_get_aspect_ratio(_node);
if (_aspect > 1) {
// 가로가 세로보다 긴 경우
flexpanel_node_style_set_background_color(_node, c_blue);
} else {
// 세로가 가로보다 긴 경우
flexpanel_node_style_set_background_color(_node, c_red);
}
예제 2: 비율에 따라 레이아웃 조정
var _aspect = flexpanel_node_style_get_aspect_ratio(_node);
if (_aspect < 1) {
// 세로형 레이아웃
flexpanel_node_style_set_padding(_node, 10, 20, 10, 20);
} else {
// 가로형 레이아웃
flexpanel_node_style_set_padding(_node, 20, 10, 20, 10);
}
예제 3: 비율을 기반으로 애니메이션 효과 적용
var _aspect = flexpanel_node_style_get_aspect_ratio(_node);
if (_aspect == 1) {
// 정사각형 비율일 때 애니메이션 적용
instance_create_layer(x, y, "Instances", obj_animation);
}
이 문서에서는 Flex Panel Node의 비율을 가져오는 방법과 이를 활용하는 다양한 예제를 소개했습니다.