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