vanilladocs
vanillapunch.com
API / misc/floatingtext

misc/floatingtext

떠오르는 텍스트 관리 노드. (데미지 숫자 / +코인 등)

Floating text manager node. (damage numbers / +coins, etc.)

FloatingTextextends WorldNode

짝Counterpart: vanilla-engine FloatingText

떠오르는 텍스트 관리 노드. (데미지 숫자 / +코인 등)

  • spawn() 으로 띄우면 위로 떠오르며 사라진다. 끝난 라벨 노드는 재사용한다.
  • 씬 뿌리에 addChild 해 두고 월드 좌표로 띄운다.
  • 사용:
const floatingText = new FloatingText();
scene.getRoot().addChild(floatingText);
floatingText.spawn("-120", position, { color: new Color(1, 0.4, 0.4, 1) });

Floating text manager node. (damage numbers / +coins, etc.)

  • Text shown with spawn() floats upward and fades out. Finished label nodes are reused.
  • Add it to the scene root with addChild and spawn in world coordinates.
  • Usage:
const floatingText = new FloatingText();
scene.getRoot().addChild(floatingText);
floatingText.spawn("-120", position, { color: new Color(1, 0.4, 0.4, 1) });
예제Example누른 자리에 피해 숫자 띄우기Pop up damage numbers where pressed
import { Engine, EngineConfiguration, Scene, FloatingText, Vector2, Color } from "./build/vanilla.js";

const floatingText = new FloatingText();

class MainScene extends Scene {
	initialize(engine) {
		super.initialize(engine);
		const root = this.getRoot();
		root.addChild(floatingText);
		floatingText.spawn("-120", Vector2.create(320, 180), { color: new Color(1, 0.4, 0.4, 1) });
		floatingText.spawn("+5", Vector2.create(200, 220), { fontSize: 30, duration: 1.2, jitter: 0 });
		console.log(floatingText.getActiveCount());
	}

	touchPress(viewInputPosition) {
		super.touchPress(viewInputPosition);
		floatingText.spawn("+1", viewInputPosition);
	}
}

const engineConfiguration = new EngineConfiguration();
const engine = new Engine(engineConfiguration);
engine.run(new MainScene());
생성자constructorconstructor()#0.3.0 부터since 0.3.0소스source

생성.

Constructor.

짝Counterpart: vanilla-engine FloatingText.new

메서드methodspawn(text, worldPosition, options = {})#0.3.0 부터since 0.3.0소스source

텍스트 띄우기.

Spawns text.

textstring
띄울 글.Text to show.
worldPositionVector2
띄울 자리. (이 노드의 지역 좌표로 놓는다, 씬 뿌리에 붙였으면 월드 좌표, 가로로 jitter 만큼 흔든다)Position to show at. (placed in this node's local coordinates, world coordinates if attached to the scene root, jittered horizontally by jitter)
optionsobject
{ color?, fontSize = 22, rise = 46, duration = 0.8, jitter = 10, bold = true }

짝Counterpart: vanilla-engine FloatingText.spawn

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

갱신. (떠오름 + 사라짐 + 회수)

Update. (float + fade + recycle)

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

떠 있는 항목 수 반환.

Returns the number of floating items.

반환Returnsnumber 떠 있는 항목 수.Number of floating items.

짝Counterpart: vanilla-engine FloatingText.get_active_count

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

모두 지우기.

Clears all.

짝Counterpart: vanilla-engine FloatingText.clear