Callbacks

μ†Œκ°œ

슀크립트 κ°œλ°œμžκ°€ μ§€μ •ν•œ ν‚€λ₯Ό ν”Œλ ˆμ΄μ–΄κ°€ λˆŒλ €μ„ λ•Œ λ˜λŠ” 슀크립트 κ°œλ°œμžκ°€ μ§€μ •ν•œ 지점에 λ„μ°©ν–ˆμ„ λ•Œ λ“±, 쑰건을 μ„€μ •ν•˜μ—¬ ν”Œλ ˆμ΄μ–΄κ°€ 쑰건을 λ‹¬μ„±ν–ˆμ„ 경우 λ™μž‘ν•˜λŠ” ν•¨μˆ˜λ“€ μž…λ‹ˆλ‹€.

이름
μ„€λͺ…

runLater

μ§€μ •ν•œ μ‹œκ°„(초) ν›„ λ™μž‘ν•˜λŠ” ν•¨μˆ˜ μž…λ‹ˆλ‹€.

addOnTileTouched

μ§€μ •ν•œ x, y μ’Œν‘œμ— ν”Œλ ˆμ΄μ–΄κ°€ λ„μ°©ν–ˆμ„ λ•Œ μ‹€ν–‰λ˜λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.

addOnLocationTouched

μ§€μ •ν•œ β€˜μ§€μ •μ˜μ—­β€™μ— ν”Œλ ˆμ΄μ–΄κ°€ λ„μ°©ν–ˆμ„ λ•Œ μ‹€ν–‰λ˜λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.

addOnKeyDown

ν”Œλ ˆμ΄μ–΄κ°€ μ§€μ •λœ ν‚€λ₯Ό λˆŒλ €μ„ λ•Œ μ‹€ν–‰λ˜λŠ” ν•¨μˆ˜ μž…λ‹ˆλ‹€.

setTimeout

μ§€μ •ν•œ μ‹œκ°„(ms) ν›„ ν•¨μˆ˜λ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.

setInterval

μ§€μ •ν•œ μ‹œκ°„(ms) κ°„κ²©μœΌλ‘œ ν•¨μˆ˜λ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.

addMobileButton

λͺ¨λ°”일 ν™˜κ²½μ—μ„œ μ»€μŠ€ν…€ λͺ¨λ°”일 λ²„νŠΌμ„ μΆ”κ°€ν•˜κ³ , λ²„νŠΌμ„ λˆŒλ €μ„ λ•Œ λ™μž‘ν•˜λŠ” ν•¨μˆ˜λ₯Ό μ§€μ •ν•©λ‹ˆλ‹€.

putMobilePunch

λͺ¨λ°”일 ν™˜κ²½μ—μ„œ νŽ€μΉ˜ λ²„νŠΌμ„ μΆ”κ°€ν•©λ‹ˆλ‹€.

putMobilePunchWithIcon

λ‘œλ“œν•œ μ΄λ―Έμ§€λ‘œ νŽ€μΉ˜ λ²„νŠΌμ„ λ§Œλ“€μ–΄ μΆ”κ°€ν•©λ‹ˆλ‹€.

πŸ“š API μ„€λͺ… 및 예제

Callbacks ν•¨μˆ˜ ν•œ λˆˆμ— 보기

// time(초) 후에 callback ν•¨μˆ˜λ₯Ό μ‹€ν–‰
App.runLater(callback, time: number)

// ν”Œλ ˆμ΄μ–΄κ°€ ν•΄λ‹Ή μœ„μΉ˜μ˜ 타일과 λΆ€λ”ͺν˜”μ„ λ•Œ μ‹€ν–‰
App.addOnTileTouched(x: number, y: number, callback)

// ν”Œλ ˆμ΄μ–΄κ°€ μ§€μ •ν•œ μœ„μΉ˜μ™€ λΆ€λ”ͺν˜”μ„ λ•Œ μ‹€ν–‰
App.addOnLocationTouched(name: string, callback)

// ν”Œλ ˆμ΄μ–΄κ°€ μ§€μ •λœ ν‚€λ₯Ό λˆŒλ €μ„ λ•Œ μ‹€ν–‰
App.addOnKeyDown(keycode : number, callback);

// time(ms) 후에 callback ν•¨μˆ˜λ₯Ό μ‹€ν–‰
setTimeout(callback, time: number)

// time(ms) ν›„ ν•¨μˆ˜λ₯Ό μ‹€ν–‰
setInterval(callback, time: number)

// λͺ¨λ°”일 ν™˜κ²½μ—μ„œ μ»€μŠ€ν…€ λͺ¨λ°”일 λ²„νŠΌμ„ μΆ”κ°€ν•˜κ³ , λ²„νŠΌμ„ λˆŒλ €μ„ λ•Œ λ™μž‘ν•˜λŠ” ν•¨μˆ˜λ₯Ό μ§€μ •
App.addMobileButton(anchor: number, posX: number, posY: number, function(player){} )

// λͺ¨λ°”일 ν™˜κ²½μ—μ„œ νŽ€μΉ˜ λ²„νŠΌ μΆ”κ°€/μ œκ±°ν•©λ‹ˆλ‹€.
App.putMobilePunch(enable: boolean = true)

// λ‘œλ“œν•œ μ΄λ―Έμ§€λ‘œ νŽ€μΉ˜ λ²„νŠΌμ„ λ§Œλ“€μ–΄ μΆ”κ°€ν•©λ‹ˆλ‹€.
App.putMobilePunchWithIcon(icon: ScriptDynamicResource)

runLater

App.runLater(function(){}, time: number);

time(초) 후에 callback ν•¨μˆ˜λ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.

νŒŒλΌλ―Έν„°

이름
νƒ€μž…
μ„€λͺ…

time

Number

λͺ‡ 초 후에 μ‹€ν–‰ 될 μ§€λ₯Ό μ •ν•˜λŠ” μ‹œκ°„ (초)

예제

앱이 μ‹œμž‘λ˜κ³  5초 ν›„ λ©”μ‹œμ§€ 좜λ ₯해보기

App.onStart.Add(function () {
	App.runLater(function() {
		App.showCenterLabel("λ©”μ‹œμ§€");
	}, 5);
});

addOnTileTouched

App.addOnTileTouched(x: number, y: number, function(player){})

μ§€μ •ν•œ x, yμ’Œν‘œμ— ν”Œλ ˆμ΄μ–΄κ°€ 도착할 경우 callback ν•¨μˆ˜λ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.

νŒŒλΌλ―Έν„°

이름
νƒ€μž…
μ„€λͺ…

x, y

number

μ§€μ • ν•  x, y μ’Œν‘œ

예제

ν”Œλ ˆμ΄μ–΄κ°€ μ§€μ • μ’Œν‘œμ— 도착 ν–ˆμ„ λ•Œ λ©”μ‹œμ§€ 좜λ ₯해보기

// ν”Œλ ˆμ΄μ–΄κ°€ 5, 5 μ’Œν‘œμ— λ„μ°©ν•œ 경우
App.addOnTileTouched(5, 5, function (player) {
	App.showCenterLabel(`${player.name}λ‹˜μ΄ (5, 5) μ’Œν‘œμ— 도착!`);
});

addOnLocationTouched

addOnLocationTouched(name: string, function(player){})

ν”Œλ ˆμ΄μ–΄κ°€ λ§΅μ—λ””ν„°μ—μ„œ μ§€μ •ν•œ β€˜μ§€μ •μ˜μ—­β€™μ— λ„μ°©ν–ˆμ„ λ•Œ callback ν•¨μˆ˜λ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.

νŒŒλΌλ―Έν„°

이름
νƒ€μž…
μ„€λͺ…

name

String

λ§΅ μ—λ””ν„°μ—μ„œ μ§€μ •ν•œ β€˜μ§€μ • μ˜μ—­β€™μ˜ 이름

player

Player

μ§€μ • μ˜μ—­μ— λ„μ°©ν•œ ν”Œλ ˆμ΄μ–΄λ₯Ό κ°€λ₯΄ν‚΄ νŒŒλΌλ―Έν„°μ˜ 이름은 μž„μ˜λ‘œ μ§€μ • κ°€λŠ₯

예제

ν”Œλ ˆμ΄μ–΄κ°€ μ§€μ • μ˜μ—­μ— λ„μ°©ν–ˆμ„ λ•Œ λ©”μ‹œμ§€ 좜λ ₯해보기

// ν”Œλ ˆμ΄μ–΄κ°€ 이름이 "myLocation"인 μ˜μ—­μ— λ„μ°©ν–ˆμ„ λ•Œ μ‹€ν–‰
App.addOnLocationTouched("myLocation", function(player){
	App.showCenterLabel(`${player.name}λ‹˜μ΄ myLocation에 λ„μ°©ν–ˆμŠ΅λ‹ˆλ‹€.`)
});

addOnKeyDown

App.addOnKeyDown(keycode : number, function(player){});

ν”Œλ ˆμ΄μ–΄κ°€ μ§€μ •λœ ν‚€λ₯Ό λˆŒλ €μ„ λ•Œ callback ν•¨μˆ˜λ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.

νŒŒλΌλ―Έν„°

이름
νƒ€μž…
μ„€λͺ…

keycode

Number

킀에 ν•΄λ‹Ήν•˜λŠ” 숫자 μžλ°”μŠ€ν¬λ¦½νŠΈ ν‚€μ½”λ“œ ν‘œ

player

Player

ν•΄λ‹Ή ν‚€λ₯Ό λˆ„λ₯Έ ν”Œλ ˆμ΄μ–΄λ₯Ό κ°€λ₯΄ν‚΄ player νŒŒλΌλ―Έν„° 이름은 μž„μ˜λ‘œ λ³€κ²½ κ°€λŠ₯

예제

aλ₯Ό λˆŒλ €μ„ λ•Œ λ©”μ‹œμ§€ 좜λ ₯해보기 ( a의 ν‚€μ½”λ“œ: 65 )

// ν”Œλ ˆμ΄μ–΄κ°€ aλ₯Ό λˆŒλ €μ„ λ•Œ μ‹€ν–‰
App.addOnKeyDown(65, function(player){
	App.sayToAll(`${player.name}λ‹˜μ΄ aν‚€λ₯Ό λˆŒλ €μŠ΅λ‹ˆλ‹€.`)
});

setTimeout

setTimeout(function(){}, time: number);

time(ms) 후에 callback ν•¨μˆ˜λ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.

νŒŒλΌλ―Έν„°

이름
νƒ€μž…
μ„€λͺ…

time

Number

callback ν•¨μˆ˜ μ‹€ν–‰ μ „ λŒ€κΈ° μ‹œκ°„ (ms)

예제

앱이 μ‹œμž‘λ˜κ³  5초 ν›„ λ©”μ‹œμ§€ 좜λ ₯해보기

App.onStart.Add(function () {
	setTimeout(function () {
		App.sayToAll("5μ΄ˆν›„ λ©”μ‹œμ§€ 좜λ ₯");
	}, 5000);
});

setInterval

setInterval(function(){}, time: number);

time(ms) κ°„κ²©μœΌλ‘œ callback ν•¨μˆ˜λ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.

νŒŒλΌλ―Έν„°

이름
νƒ€μž…
μ„€λͺ…

time

Number

callback ν•¨μˆ˜ μ‹€ν–‰ μ£ΌκΈ° (ms)

예제

앱이 μ‹œμž‘λ˜κ³  1초 κ°„κ²©μœΌλ‘œ λ©”μ‹œμ§€ 좜λ ₯해보기

let time = 0;
App.onStart.Add(function () {
	setInterval(function () {
		App.sayToAll(`μ•± μ‹€ν–‰ ${++time}초 κ²½κ³Ό`);
	}, 1000);
});

addMobileButton

App.addMobileButton( anchor: number, posX: number, posY: number, function(player){} )

λͺ¨λ°”일 ν™˜κ²½μ—μ„œ μ»€μŠ€ν…€ λͺ¨λ°”일 λ²„νŠΌμ„ μΆ”κ°€ν•˜κ³ , λ²„νŠΌμ„ λˆŒλ €μ„ λ•Œ λ™μž‘ν•˜λŠ” ν•¨μˆ˜λ₯Ό μ§€μ •ν•©λ‹ˆλ‹€.

λͺ¨λ°”μΌλ²„νŠΌμ˜μ„μ΄λ―Έμ§€λ₯Ό μ›ν•˜λŠ” μ΄λ―Έμ§€λ‘œ λ³€κ²½ ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

λͺ¨λ°”μΌλ²„νŠΌ 이미지 λ³€κ²½ν•˜κΈ°

νŒŒλΌλ―Έν„°

이름
νƒ€μž…
μ„€λͺ…

anchor

Number

λͺ¨λ°”일 λ²„νŠΌμ˜ μœ„μΉ˜λ₯Ό 숫자둜 μž…λ ₯ν•©λ‹ˆλ‹€. TOP = 0, TOP_LEFT = 1, TOP_RIGHT = 2, MIDDLE = 3, MIDDLE_LEFT = 4, MIDDLE_RIGHT = 5, BOTTOM = 6, BOTTOM_LEFT = 7, BOTTOM_RIGHT = 8

posX

Number

λͺ¨λ°”일 λ²„νŠΌ x λ°©ν–₯ μ˜€ν”„μ…‹ 수치

posY

Number

λͺ¨λ°”일 λ²„νŠΌ y λ°©ν–₯ μ˜€ν”„μ…‹ 수치

player

Player

λͺ¨λ°”일 λ²„νŠΌμ„ λˆ„λ₯Έ ν”Œλ ˆμ΄μ–΄λ₯Ό κ°€λ₯΄ν‚΄

예제

λͺ¨λ°”일 λ²„νŠΌ 좔가해보기

예제λ₯Ό μ°Έκ³ ν•΄ λ²„νŠΌμ˜ μœ„μΉ˜λ₯Ό μ„€μ •ν•΄λ³΄μ„Έμš”!
App.onStart.Add(function () {
	// Bottom_Right
	App.addMobileButton(8, 145, 75, function (player) {
		App.sayToAll(`${player.name}, Bottom λ²„νŠΌA`);
	});
	// Bottom_Right
	App.addMobileButton(8, 145, -20, function (player) {
		App.sayToAll(`${player.name}, Bottom λ²„νŠΌB`);
	});
	// Top
	App.addMobileButton(0, 0, 400, function (player) {
		App.sayToAll(`${player.name}, TOP λ²„νŠΌ`);
	});
	// Top_Left
	App.addMobileButton(1, 50, 400, function (player) {
		App.sayToAll(`${player.name}, TOP_LEFT λ²„νŠΌ`);
	});
	// Top_right
	App.addMobileButton(2, 50, 400, function (player) {
		App.sayToAll(`${player.name}, TOP_RIGHT λ²„νŠΌ`);
	});
	// Middle
	App.addMobileButton(3, 0, 100, function (player) {
		App.sayToAll(`${player.name}, MIDDLE λ²„νŠΌ`);
	});
	// Middle_left
	App.addMobileButton(4, 50, 100, function (player) {
		App.sayToAll(`${player.name}, MIDDLE LEFT λ²„νŠΌ`);
	});
	// Middle_right
	App.addMobileButton(5, 50, 100, function (player) {
		App.sayToAll(`${player.name}, MIDDLE RIGHT λ²„νŠΌ`);
	});
});

putMobilePunch

App.putMobilePunch(enable: boolean = true)

enable이 true이면 λͺ¨λ°”일 ν™˜κ²½μ—μ„œ νŽ€μΉ˜ λ²„νŠΌμ΄ μΆ”κ°€λ©λ‹ˆλ‹€.

νŒŒλΌλ―Έν„°

이름
νƒ€μž…
μ„€λͺ…

enable

Boolean

λͺ¨λ°”일 νŽ€μΉ˜ λ²„νŠΌ ν™œμ„±ν™” μ—¬λΆ€ ( κΈ°λ³Έ κ°’ true )

예제

Q λ²„νŠΌμ„ 눌러 λͺ¨λ°”일 ν™˜κ²½μ— νŽ€μΉ˜ λ²„νŠΌμ„ μΆ”κ°€/제거 해보기

let punchButton = false;
// Q λ²„νŠΌμ„ λˆ„λ₯΄λ©΄ λ™μž‘ν•˜λŠ” ν•¨μˆ˜
App.addOnKeyDown(81, function (player) {
	if (!punchButton) {
		punchButton = true;
		App.putMobilePunch();
	} else {
		punchButton = false;
		App.putMobilePunch(false);
	}
});

putMobilePunchWithIcon

App.putMobilePunchWithIcon(icon: ScriptDynamicResource)

λ‘œλ“œν•œ μ΄λ―Έμ§€λ‘œ νŽ€μΉ˜ λ²„νŠΌμ„ λ§Œλ“€μ–΄ μΆ”κ°€ν•©λ‹ˆλ‹€.

νŒŒλΌλ―Έν„°

이름
νƒ€μž…
μ„€λͺ…

icon

ScriptDynamicResource

App.loadSpriteSheet ν•¨μˆ˜λ‘œ λ‘œλ“œν•œ 이미지 λ¦¬μ†ŒμŠ€

예제

Q λ²„νŠΌμ„ 눌러 λͺ¨λ°”일 ν™˜κ²½μ— λ‘œλ“œν•œ μ΄λ―Έμ§€λ‘œ νŽ€μΉ˜ λ²„νŠΌ μΆ”κ°€ν•˜κΈ°

νŽ€μΉ˜μ•„μ΄μ½˜
const punchIcon = App.loadSpritesheet("punchIcon.png")
// Q λ²„νŠΌμ„ λˆ„λ₯΄λ©΄ λ™μž‘ν•˜λŠ” ν•¨μˆ˜
App.addOnKeyDown(81, function (player) {
	App.putMobilePunchWithIcon(punchIcon);
});

뢀둝

μžλ°”μŠ€ν¬λ¦½νŠΈ ν‚€μ½”λ“œ ν‘œ

Last updated

Was this helpful?