vanilladocs
vanillapunch.com
API / ui/uispinner

ui/uispinner

회전 로딩 인디케이터.

Spinning loading indicator.

UISpinnerextends WorldNode

짝Counterpart: vanilla-engine UISpinner

회전 로딩 인디케이터.

  • 원 둘레에 점 여러 개를 놓고 밝기가 꼬리처럼 돌아가는 표준 스피너.
  • 사용:
const spinner = new UISpinner({ radius: 9, dotCount: 10 });
someNode.addChild(spinner);
spinner.setLocalPosition(Vector2.create(x, y));

Spinning loading indicator.

  • A standard spinner with several dots around a circle whose brightness rotates like a tail.
  • Usage:
const spinner = new UISpinner({ radius: 9, dotCount: 10 });
someNode.addChild(spinner);
spinner.setLocalPosition(Vector2.create(x, y));
예제Example화면 가운데에 스피너 돌리기Spinning a spinner in the middle of the screen
import { Engine, EngineConfiguration, UIScene, UISpinner, Color, Vector2 } from "./build/vanilla.js";

class SpinnerScene extends UIScene {
	create() {
		super.create();
		const spinner = new UISpinner({ radius: 16, dotCount: 12, dotRadius: 3, color: new Color(0.4, 0.7, 1, 1), rotationSpeed: 0.8 });
		spinner.setLocalPosition(Vector2.create(320, 180));
		spinner.setDotColor(new Color(1, 0.8, 0.3, 1));
		const root = this.getRoot();
		root.addChild(spinner);
	}
}

const engineConfiguration = new EngineConfiguration();
const engine = new Engine(engineConfiguration);
const scene = new SpinnerScene();
scene.setLoadingMinDurationMs(0);
engine.run(scene);
생성자constructorconstructor(options = {})#0.3.0 부터since 0.3.0소스source

생성.

Constructor.

optionsobject
{ radius = 9, dotCount = 10, dotRadius = 2, color?, rotationSpeed = 1 }

짝Counterpart: vanilla-engine UISpinner.new

메서드methodtick(timeDelta)#0.3.0 부터since 0.3.0소스source

갱신. (밝기 꼬리 회전)

Update. (rotates the brightness tail)

timeDeltanumber
지난 프레임부터의 시간. (초)Time since the last frame. (Seconds)
메서드methodcalculateDotOpacity(dotIndex)#0.4.0 부터since 0.4.0소스source

점 투명도 계산. (점 순서 비율에서 위상을 뺀 꼬리 비율이 작을수록 밝다)

  • 점이 없으면(dotCount 0) 순서 비율을 0 으로 본다.

Computes a dot's opacity. (the smaller the tail ratio, the dot order ratio minus the phase, the brighter)

  • With no dots (dotCount 0) the order ratio is taken as 0.
dotIndexnumber
점 순서. (0 부터, 오른쪽에서 시작해 시계 방향)Dot index. (from 0, starting at the right and going clockwise)

반환Returnsnumber 불투명도. (0.15 ~ 1, 밝기 꼬리의 머리 점이 1)Opacity. (0.15 ~ 1, the head dot of the brightness tail is 1)

짝Counterpart: vanilla-engine UISpinner.calculate_dot_opacity

메서드methodgetDotColor()#0.4.0 부터since 0.4.0소스source

점 색 반환.

Returns the dot color.

반환ReturnsColor 점 색. (복제하지 않은 원본)Dot color. (the original, not cloned)

짝Counterpart: vanilla-engine UISpinner.get_dot_color

메서드methodgetRotationSpeed()#0.4.0 부터since 0.4.0소스source

회전 속도 반환. (초당 바퀴 수)

Returns the rotation speed. (turns per second)

반환Returnsnumber 초당 바퀴 수.Turns per second.

짝Counterpart: vanilla-engine UISpinner.get_rotation_speed

메서드methodgetDotNodes()#0.4.0 부터since 0.4.0소스source

점 노드 목록 반환.

Returns the dot node list.

반환ReturnsWorldNode[] 점 노드 목록의 복사본. (점 노드는 같은 것)Copy of the dot node list. (the dot nodes are the same)

짝Counterpart: vanilla-engine UISpinner.get_dot_nodes

메서드methodsetDotColor(dotColor)#0.3.0 부터since 0.3.0소스source

점 색 설정.

Sets the dot color.

dotColorColor | string
점 색. (복제해 모든 점의 Paint 에 넣는다)Dot color. (cloned and set on every dot's Paint)

짝Counterpart: vanilla-engine UISpinner.set_dot_color

메서드methodsetRotationSpeed(rotationSpeed)#0.3.0 부터since 0.3.0소스source

회전 속도 설정. (초당 바퀴 수)

Sets the rotation speed. (turns per second)

rotationSpeednumber
초당 바퀴 수. (음수면 거꾸로 돈다)Turns per second. (negative turns backward)

짝Counterpart: vanilla-engine UISpinner.set_rotation_speed