Methods

์†Œ๊ฐœ

ํ™”๋ฉด์— UI๋ฅผ ํ‘œ์‹œ, ์œ ์ € ์ด๋™ ๋˜๋Š” ๊ฐ•ํ‡ด, ์‚ฌ์šด๋“œ ์žฌ์ƒ ๋“ฑ ํŽธ๋ฆฌํ•œ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๋Š” ํ•จ์ˆ˜๋“ค ์ž…๋‹ˆ๋‹ค.

Methods ํ•จ์ˆ˜๋Š” ์šฉ๋„์— ๋”ฐ๋ผ UI , User Control, Sound, ํ†ต์‹ , ๊ณตํ†ต ๋ฉ”์†Œ๋“œ๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

UI

์ด๋ฆ„
์„ค๋ช…

loadSpritesheet

์Šคํ”„๋ผ์ดํŠธ ์‹œํŠธ ๊ทธ๋ฆผ ํŒŒ์ผ์„ ์ฝ์–ด ๊ฐ์ฒดํ™”ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

showCenterLabel

๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ ์ง€์ •๋œ ์œ„์น˜์— text๋ฅผ 3์ดˆ๊ฐ„ ํ‘œ์‹œํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

showCustomLabel

๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ ์ง€์ •๋œ ์œ„์น˜์— text๋ฅผ 3์ดˆ๊ฐ„ ํ‘œ์‹œํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค. text ๋ถ€๋ถ„์— span ํƒœ๊ทธ๋ฅผ ๋„ฃ์–ด ํ…์ŠคํŠธ๋ฅผ ๊พธ๋ฐ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

sayToAll

๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์˜ ์ฑ„ํŒ…์ฐฝ์— text ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

sayToStaffs

Staff ๊ถŒํ•œ ์ด์ƒ์˜ ํ”Œ๋ ˆ์ด์–ด์˜ ์ฑ„ํŒ…์ฐฝ์— text ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

showWidget

๋ชจ๋“ ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ ์ง€์ •๋œ align์˜ ์œ„์น˜์— htmlํŒŒ์ผ์„ ์œ„์ ฏ์œผ๋กœ ๋ถˆ๋Ÿฌ์˜ค๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

showYoutubeWidget

๋งํฌ์— ํ•ด๋‹นํ•˜๋Š” Youtube ์ปจํ…์ธ ๋ฅผ ์œ„์ ฏ์œผ๋กœ ๋ถˆ๋Ÿฌ์˜ต๋‹ˆ๋‹ค.

Control

์ด๋ฆ„
์„ค๋ช…

spawnPlayer

ํ”Œ๋ ˆ์ด์–ด๋ฅผ ์ง€์ •ํ•œ x, y ์ขŒํ‘œ๋กœ ์ด๋™ ์‹œํ‚ค๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

kickPlayer

ํ”Œ๋ ˆ์ด์–ด๋ฅผ ์ถ”๋ฐฉํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

forceDestroy

๋ฏธ๋‹ˆ๊ฒŒ์ž„ ์•ฑ์„ ๊ฐ•์ œ ์ข…๋ฃŒํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

clearChat

๋ชจ๋“  ์ฑ„ํŒ… ๋‚ด์šฉ์„ ์‚ญ์ œํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

getPlayerByID

id ์— ํ•ด๋‹นํ•˜๋Š” ํ”Œ๋ ˆ์ด์–ด๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

Sound

์ด๋ฆ„
์„ค๋ช…

playSound

์‚ฌ์šด๋“œ ํŒŒ์ผ์„ ์žฌ์ƒํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

playSoundLink

์‚ฌ์šด๋“œ URL์„ ์žฌ์ƒํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

stopSound

์žฌ์ƒ ์ค‘์ธ ๋ชจ๋“  ์‚ฌ์šด๋“œ๋ฅผ ๋ฉˆ์ถ”๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

ํ†ต์‹ 

์ด๋ฆ„
์„ค๋ช…

httpGet

http get ์š”์ฒญ์„ ๋ณด๋‚ด๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

httpPost

Form-Data ํ˜•ํƒœ์˜ http post ์š”์ฒญ์„ ๋ณด๋‚ด๋Š” ํ•จ์ˆ˜ ์ž…๋‹ˆ๋‹ค.

httpPostJson

JSON ํ˜•ํƒœ์˜ http post ์š”์ฒญ์„ ๋ณด๋‚ด๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

๊ณตํ†ต

์ด๋ฆ„
์„ค๋ช…

sendUpdated

App, Player ๊ด€๋ จ ํ•„๋“œ ๊ฐ’์ด ๋ณ€๊ฒฝ๋˜๋ฉด ๋ณ€๊ฒฝ ๊ฐ’์„ ์ ์šฉํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

๐Ÿ“š API ์„ค๋ช… ๋ฐ ์˜ˆ์ œ

๐ŸŽจ UI Methods

UI ํ•จ์ˆ˜ ํ•œ ๋ˆˆ์— ๋ณด๊ธฐ

// ์Šคํ”„๋ผ์ดํŠธ ์‹œํŠธ ๊ทธ๋ฆผ ํŒŒ์ผ์„ ์ฝ์–ด ๊ฐ์ฒดํ™”
App.loadSpritesheet(fileName: string, frameWidth: number, frameHeight: number, anims: array, frameRate: number): ScriptDynamicResource

// ๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ ์ง€์ •๋œ ์œ„์น˜์— ํ•ด๋‹น text๋ฅผ 1์ดˆ๊ฐ„ ํ‘œ์‹œ
App.showCenterLabel(text: string, color: uint = 0xFFFFFF, bgColor: uint = 0x000000, offset: int = 0, time: int = 3000)

// ๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ ์ง€์ •๋œ ์œ„์น˜์— ํ•ด๋‹น text๋ฅผ 3์ดˆ๊ฐ„ ํ‘œ์‹œ, ์ปค์Šคํ„ฐ๋งˆ์ด์ง• ๊ฐ€๋Šฅ
App.showCustomLabel(text: string, color: number = 0xFFFFFF, bgColor: number = 0x000000, offset: number = 0, width = 100, opacity = 0.6, time: int = 3000);

// ์ฑ„ํŒ…์ฐฝ์— ํ•ด๋‹น text๋‚ด์šฉ์„ ์ถœ๋ ฅ
App.sayToAll(text: string, color: uint = 0xFFFFFF)

// ๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ ์ง€์ •๋œ align์˜ ์œ„์น˜์— ํ•ด๋‹น htmlํŒŒ์ผ์„ ์œ„์ ฏ์œผ๋กœ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
App.showWidget(fileName: string, align: string, width: number, height: number): ScriptWidget

// ๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ ์ง€์ •๋œ align์˜ ์œ„์น˜์— ํ•ด๋‹น YouTube link์˜ ๋™์˜์ƒ์„ ์žฌ์ƒ์‹œํ‚ด
App.showYoutubeWidget(link: string, align: string, width: number, height: number): ScriptWidget

loadSpritesheet

App.loadSpritesheet(fileName: string, frameWidth: number, frameHeight: number, anims: array, frameRate: number): ScriptDynamicResource

์Šคํ”„๋ผ์ดํŠธ ์‹œํŠธ ๊ทธ๋ฆผ ํŒŒ์ผ์„ ์ฝ์–ด ๊ฐ์ฒดํ™”ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

ScriptDynamicResource์— ๋Œ€ํ•œ ์ดํ•ด๋ฅผ ๋•๋Š” ์Šคํ”„๋ผ์ดํŠธ์‹œํŠธ ์ดํ•ดํ•˜๊ธฐ ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•ด๋ณด์„ธ์š”!

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

fileName

String

๋ถˆ๋Ÿฌ์˜ฌ ํŒŒ์ผ์˜ ์ด๋ฆ„

frameWidth frameHeight

number

ํ•œ ํ”„๋ ˆ์ž„์˜ ๊ฐ€๋กœ, ์„ธ๋กœ ํ”ฝ์…€ ํฌ๊ธฐ

anims

Array

์• ๋‹ˆ๋ฉ”์ด์…˜์œผ๋กœ ์ง€์ •ํ•  frame ์ด๋ฏธ์ง€ ๋ฒˆํ˜ธ ๋ฐฐ์—ด

frameRate

number

ํ”„๋ ˆ์ž„ ํ•˜๋‚˜ ๋‹น ๋ฐ์ดํ„ฐ๋ฅผ ํ‘œ์‹œํ•˜๋Š” ์†๋„ frameRate: 8 โ†’ 1์ดˆ์— 8๊ฐœ์˜ ์ด๋ฏธ์ง€๋ฅผ ๋ณด์—ฌ์คŒ

์˜ˆ์ œ

ํŽ˜์ธํŠธ๋งจ - ๋ธ”๋ฃจ๋งจ ์Šคํ”„๋ผ์ดํŠธ ์ด๋ฏธ์ง€ ์ ์šฉํ•ด๋ณด๊ธฐ

// ํ•œ ํ”„๋ ˆ์ž„์˜ ์‚ฌ์ด์ฆˆ 48x64
let blueman = App.loadSpritesheet('blueman.png', 48, 64, {
    left: [5, 6, 7, 8, 9], // ์ขŒ๋ฐฉํ–ฅ ์ด๋™ ์ด๋ฏธ์ง€
    up: [15, 16, 17, 18, 19],
    down: [0, 1, 2, 3, 4],
    right: [10, 11, 12, 13, 14],
		dance: [20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],
		down_jump: [38],
		left_jump: [39],
		right_jump: [40],
		up_jump: [41],
}, 8);
// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ž…์žฅํ•˜๋ฉด ์บ๋ฆญํ„ฐ ์ด๋ฏธ์ง€๊ฐ€ ๋ฐ”๋€œ
App.onJoinPlayer.Add(function(player){
	player.sprite = blueman;
	player.sendUpdated();
});

showCenterLabel

App.showCenterLabel(text: string, color: uint = 0xFFFFFF, bgColor: uint = 0x000000, offset: number = 0, time: number = 3000)

๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ ์ง€์ •๋œ ์œ„์น˜์— text๋ฅผ 3์ดˆ๊ฐ„ ํ‘œ์‹œํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

text

String

๋ผ๋ฒจ์— ์ถœ๋ ฅํ•  ํ…์ŠคํŠธ

color

Uint

bgColor

Uint

๋ฉ”์‹œ์ง€๊ฐ€ ์ถœ๋ ฅ๋˜๋Š” ๋ผ๋ฒจ์˜ ๋ฐฐ๊ฒฝ์ƒ‰ ๊ฐ’์„ ์ž…๋ ฅํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ, ๊ฒ€์€์ƒ‰(0x000000)์œผ๋กœ ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.

offset

number

offset ๊ฐ’์ด ํด์ˆ˜๋ก ํ‘œ์‹œ๋˜๋Š” ์œ„์น˜๊ฐ€ ํ™”๋ฉด ์•„๋ž˜์ชฝ ๋ฐฉํ–ฅ์œผ๋กœ ๊ฐ€๊นŒ์›Œ์ง‘๋‹ˆ๋‹ค. ๊ฐ’์„ ์ž…๋ ฅํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ, 0์œผ๋กœ ์ง€์ •๋ฉ๋‹ˆ๋‹ค.

time

number

๋ผ๋ฒจ ํ‘œ์‹œ ์‹œ๊ฐ„ (ms), ๊ธฐ๋ณธ ๊ฐ’ 3000 ( 3์ดˆ )

์˜ˆ์ œ

๋…ธ๋ž€์ƒ‰ ๋ฐฐ๊ฒฝ ์ž…์žฅ ๋ฉ”์‹œ์ง€ ๋ผ๋ฒจ์„ 2์ดˆ๊ฐ„ ์ถœ๋ ฅํ•ด๋ณด๊ธฐ

App.onJoinPlayer.Add(function(player){
	App.showCenterLabel(`${player.name}๋‹˜์ด ์ž…์žฅํ•˜์…จ์Šต๋‹ˆ๋‹ค.`, 0x000000, 0xFFFF00, 200, 2000); // ๋…ธ๋ž€์ƒ‰ ๋ฐฐ๊ฒฝ, ๊ฒ€์ •์ƒ‰ ๊ธ€์”จ๋กœ ํ‘œ์‹œํ•˜๊ธฐ
});

showCustomLabel

App.showCustomLabel(text: string, color: number = 0xFFFFFF, bgColor: number = 0x000000, offset: number = 0, width = 100, opacity = 0.6, time: number = 3000, option: object = null);

๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ ์ง€์ •๋œ ์œ„์น˜์— text๋ฅผ 3์ดˆ๊ฐ„ ํ‘œ์‹œํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

text ๋ถ€๋ถ„์— span ํƒœ๊ทธ๋ฅผ ๋„ฃ์–ด ํ…์ŠคํŠธ๋ฅผ ๊พธ๋ฐ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

text

String

๋ผ๋ฒจ์— ์ถœ๋ ฅํ•  ํ…์ŠคํŠธ ( span ํƒœ๊ทธ ํ—ˆ์šฉ )

color

Uint

์ถœ๋ ฅํ•  ๊ธ€์”จ์˜ ์ƒ‰ (HexCode) ๊ฐ’์„ ์ž…๋ ฅํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ, ํฐ์ƒ‰(0xFFFFFF)์œผ๋กœ ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.

bgColor

Uint

offset

number

offset ๊ฐ’์ด ํด์ˆ˜๋ก ํ‘œ์‹œ๋˜๋Š” ์œ„์น˜๊ฐ€ ํ™”๋ฉด ์•„๋ž˜์ชฝ ๋ฐฉํ–ฅ์œผ๋กœ ๊ฐ€๊นŒ์›Œ์ง‘๋‹ˆ๋‹ค. ๊ฐ’์„ ์ž…๋ ฅํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ, 0์œผ๋กœ ์ง€์ •๋ฉ๋‹ˆ๋‹ค.

width

number

๋ผ๋ฒจ์˜ ๋„ˆ๋น„๋ฅผ n%๋กœ ์„ค์ •ํ•˜๋Š” ๊ฐ’ ์ž…๋‹ˆ๋‹ค. (๊ธฐ๋ณธ ๊ฐ’ 100)

opacity

number

๋ผ๋ฒจ์˜ ๋ฐฐ๊ฒฝ ํˆฌ๋ช…๋„๋ฅผ ์„ค์ •ํ•˜๋Š” ๊ฐ’ ์ž…๋‹ˆ๋‹ค. (๊ธฐ๋ณธ ๊ฐ’ 0.6, ๋ฒ”์œ„ 0 ~ 1)

time

number

๋ผ๋ฒจ ํ‘œ์‹œ ์‹œ๊ฐ„ (ms), ๊ธฐ๋ณธ ๊ฐ’ 3000 ( 3์ดˆ )

์˜ต์…˜

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

key

String

๋ผ๋ฒจ์— ํ‚ค ๊ฐ’์„ ํ• ๋‹นํ•˜์—ฌ, ์„œ๋กœ ๋‹ค๋ฅธ ํ‚ค ๊ฐ’์„ ๊ฐ€์ง„ ๋ผ๋ฒจ์€ ๋™์‹œ์— ํ‘œ์‹œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

borderRadius

String

๋ผ๋ฒจ์˜ ๋ชจ์„œ๋ฆฌ์— ๋‘ฅ๊ธ€๊ธฐ๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ex) borderRadius: "8px"

fontOpacity

boolean

false๋กœ ์„ค์ •์‹œ ํฐํŠธ์— ํˆฌ๋ช…๋„๊ฐ€ ์ ์šฉ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

padding

String

๋ผ๋ฒจ ๋‚ด๋ถ€์— padding ๊ฐ’์„ ์ง€์ • ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ex) padding: "8px"

์˜ˆ์ œ

์ปค์Šคํ…€ ๋ผ๋ฒจ ์˜ˆ์ œ ์ฝ”๋“œ ํŽ˜์ด์ง€๋ฅผ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”

sayToAll

App.sayToAll(text: string, color: uint = 0xFFFFFF)

์ฑ„ํŒ…์ฐฝ์— text ๋‚ด์šฉ์„ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

text

String

์ฑ„ํŒ…์ฐฝ์— ์ถœ๋ ฅํ•  ํ…์ŠคํŠธ

color

Uint

์˜ˆ์ œ

์ž…์žฅ๋ฉ”์‹œ์ง€๋ฅผ ํ•˜๋Š˜์ƒ‰์œผ๋กœ ์ถœ๋ ฅํ•ด๋ณด๊ธฐ

// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ž…์žฅํ•  ๋•Œ ์‹คํ–‰
App.onJoinPlayer.Add(function (player) {
	App.sayToAll(`[info]${player.name} has entered.`, 0x00ffff); // ํ•˜๋Š˜์ƒ‰์œผ๋กœ ํ‘œ์‹œํ•˜๊ธฐ
});

sayToStaffs

App.sayToStaffs(text: string, color: uint = 0xFFFFFF)

Staff์ด์ƒ ๊ถŒํ•œ์˜ ์œ ์ € ์ฑ„ํŒ…์ฐฝ์— text ๋‚ด์šฉ์„ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

text

String

์ฑ„ํŒ…์ฐฝ์— ์ถœ๋ ฅํ•  ํ…์ŠคํŠธ

color

Uint

์˜ˆ์ œ

์ž…์žฅ๋ฉ”์‹œ์ง€๋ฅผ ํ•˜๋Š˜์ƒ‰์œผ๋กœ ์ถœ๋ ฅํ•ด๋ณด๊ธฐ

// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ž…์žฅํ•  ๋•Œ ์‹คํ–‰
App.onJoinPlayer.Add(function (player) {
	App.sayToStaffs(`[Staff] ${player.name} has entered.`, 0x00ffff); // ํ•˜๋Š˜์ƒ‰์œผ๋กœ ํ‘œ์‹œํ•˜๊ธฐ
});

showWidget

App.showWidget(fileName: string, align: string, width: number, height: number): ScriptWidget

๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ ์ง€์ •๋œ align์˜ ์œ„์น˜์— ํ•ด๋‹น htmlํŒŒ์ผ์„ ์œ„์ ฏ์œผ๋กœ ๋ถˆ๋Ÿฌ์˜ค๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

fileName

String

๋ถˆ๋Ÿฌ์˜ฌ ํŒŒ์ผ์˜ ์ด๋ฆ„

align

String

์œ„์ ฏ์„ ํ‘œ์‹œํ•  ์œ„์น˜ โ€™popupโ€™, โ€˜sidebarโ€™, โ€˜topโ€™, โ€˜topleftโ€™, โ€˜toprightโ€™, โ€˜middleโ€™, โ€˜middleleftโ€™, โ€˜middlerightโ€™, โ€˜bottomโ€™, โ€˜bottomleftโ€™, โ€˜bottomrightโ€™

width height

number

์œ„์ ฏ์„ ํ‘œ์‹œํ•  ์˜์—ญ์˜ ๊ฐ€๋กœ, ์„ธ๋กœ ํฌ๊ธฐ(px)

์˜ˆ์ œ

์ดˆ์„ฑํ€ด์ฆˆ ์œ„์ ฏ ๋”ฐ๋ผํ•ด๋ณด๊ธฐ

let _widget = null;
// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ž…์žฅํ•  ๋•Œ ์‹คํ–‰
App.onJoinPlayer.Add(function (player) {
	_widget = App.showWidget("widget.html", "top", 200, 300); // ํ™”๋ฉด ์ƒ๋‹จ, 200x300 ์˜์—ญ์— ์œ„์ ฏ์„ ๋ณด์—ฌ์คŒ
	_widget.sendMessage({
		timer: 15,
		answer: "ใ……ใ…ใ…‹",
	});
});

showYoutubeWidget

App.showYoutubeWidget(link: string, align: string, width: number, height: number): ScriptWidget

๋งํฌ์— ํ•ด๋‹นํ•˜๋Š” Youtube ์ปจํ…์ธ ๋ฅผ ์œ„์ ฏ์œผ๋กœ ๋ถˆ๋Ÿฌ์˜ต๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

link

String

Youtube ์ปจํ…์ธ  url

align

String

์œ„์ ฏ์„ ํ‘œ์‹œํ•  ์œ„์น˜ โ€™popupโ€™, โ€˜sidebarโ€™, โ€˜topโ€™, โ€˜topleftโ€™, โ€˜toprightโ€™, โ€˜middleโ€™, โ€˜middleleftโ€™, โ€˜middlerightโ€™, โ€˜bottomโ€™, โ€˜bottomleftโ€™, โ€˜bottomrightโ€™

width height

number

์œ„์ ฏ์„ ํ‘œ์‹œํ•  ์˜์—ญ์˜ ๊ฐ€๋กœ, ์„ธ๋กœ ํฌ๊ธฐ(px)

์˜ˆ์ œ

Youtube ์œ„์ ฏ ํ‘œ์‹œํ•ด๋ณด๊ธฐ

// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ž…์žฅํ•  ๋•Œ ์‹คํ–‰
App.onJoinPlayer.Add(function (player) {
	App.showYoutubeWidget("https://www.youtube.com/watch?v=SXnMGIR8cjY","top",600,500);
});

๐Ÿ”—Control Methods

Control ํ•จ์ˆ˜ ํ•œ ๋ˆˆ์— ๋ณด๊ธฐ

// playerID ์— ํ•ด๋‹นํ•˜๋Š” ํ”Œ๋ ˆ์ด์–ด๋ฅผ tileX, tileY ์ขŒํ‘œ๋กœ ์ด๋™์‹œํ‚จ๋‹ค.
App.spawnPlayer(playeID: string, tileX: number, tileY: number)

// playerID ์— ํ•ด๋‹นํ•˜๋Š” ํ”Œ๋ ˆ์ด์–ด๋ฅผ ์ถ”๋ฐฉํ•œ๋‹ค.
// ์ถ”๋ฐฉ๋‹นํ•œ ์œ ์ €๋Š” 24์‹œ๊ฐ„ ๋™์•ˆ ํ•ด๋‹น ์ŠคํŽ˜์ด์Šค์— ์ ‘๊ทผํ•˜์ง€ ๋ชปํ•˜๊ฒŒ ๋œ๋‹ค.
App.kickPlayer(playeID: string)

// ๋ฏธ๋‹ˆ๊ฒŒ์ž„ ์•ฑ์„ ๊ฐ•์ œ์ข…๋ฃŒ์‹œํ‚ต๋‹ˆ๋‹ค.
App.forceDestroy();

// ๋ชจ๋“  ์ฑ„ํŒ…๋‚ด์šฉ์„ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค.
App.clearChat();

//id ์— ํ•ด๋‹นํ•˜๋Š” ํ”Œ๋ ˆ์ด์–ด๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
App.getPlayerID(playerID:string);

spawnPlayer

App.spawnPlayer(playeID: string, tileX: number, tileY: number)

playerID ์— ํ•ด๋‹นํ•˜๋Š” ํ”Œ๋ ˆ์ด์–ด๋ฅผ tileX, tileY ์ขŒํ‘œ๋กœ ์ด๋™์‹œํ‚ค๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

playerID

String

ํ”Œ๋ ˆ์ด์–ด์˜ ID ๊ฐ’

tileX tileY

number

ํ”Œ๋ ˆ์ด์–ด๋ฅผ ์ด๋™์‹œํ‚ฌ x, y ์ขŒํ‘œ ๊ฐ’

์˜ˆ์ œ

์ž…์žฅํ•˜๋Š” ํ”Œ๋ ˆ์ด์–ด๋ฅผ ์ง€์ • ์ขŒํ‘œ๋กœ ์ด๋™์‹œํ‚ค๊ธฐ

// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ž…์žฅํ•  ๋•Œ ์‹คํ–‰
App.onJoinPlayer.Add(function (player) {
	App.spawnPlayer(player.id, 5, 5); // ํ”Œ๋ ˆ์ด์–ด๋ฅผ 5,5 ์œ„์น˜๋กœ ์ด๋™์‹œํ‚ค๊ธฐ
});

kickPlayer

App.kickPlayer(playerID: string)

playerID ์— ํ•ด๋‹นํ•˜๋Š” ํ”Œ๋ ˆ์ด์–ด๋ฅผ ์ถ”๋ฐฉํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

playerID

String

ํ”Œ๋ ˆ์ด์–ด์˜ ID ๊ฐ’

์˜ˆ์ œ

๊ฐ•ํ‡ด ๋ช…๋ น์–ด ๋งŒ๋“ค์–ด๋ณด๊ธฐ

โ›” ๊ฐ•ํ‡ด ๋‹นํ•œ ์ฐธ๊ฐ€์ž๋Š” 24์‹œ๊ฐ„ ๋™์•ˆ ํ•ด๋‹น ์ŠคํŽ˜์ด์Šค์— ์ ‘์†ํ•˜์ง€ ๋ชปํ•ฉ๋‹ˆ๋‹ค.

// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ฑ„ํŒ…์„ ์ž…๋ ฅํ•  ๋•Œ ์‹คํ–‰
// ๋ช…๋ น์–ด ํ˜•์‹ '!๊ฐ•ํ‡ด ๋‹‰๋„ค์ž„'
App.onSay.Add(function (player, text) {
	let players = App.players;
	if (text.indexOf("!๊ฐ•ํ‡ด ") == 0) {
		let nickname = text.slice(4);
		for (let i in players) {
			let p = players[i];
			if (p.name == nickname) {
				App.kickPlayer(p.id);
				break;
			}
		}
	}
});

forceDestroy

App.forceDestroy();

๋ฏธ๋‹ˆ๊ฒŒ์ž„ ์•ฑ์„ ๊ฐ•์ œ ์ข…๋ฃŒํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

์˜ˆ์ œ

๋ฏธ๋‹ˆ๊ฒŒ์ž„ ์•ฑ์„ ๊ฐ•์ œ ์ข…๋ฃŒ์‹œํ‚ค๊ธฐ

// q ํ‚ค๋ฅผ ๋ˆ„๋ฅด๋ฉด ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜
App.addOnKeyDown(81, function (player) {
	App.forceDestroy();
});

clearChat

App.clearChat();

๋ชจ๋“  ์ฑ„ํŒ… ๋‚ด์šฉ์„ ์‚ญ์ œํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

์˜ˆ์ œ

Q๋ฅผ ๋ˆŒ๋Ÿฌ ์ฑ„ํŒ… ๋‚ด์šฉ ์ง€์šฐ๊ธฐ

// q ํ‚ค๋ฅผ ๋ˆ„๋ฅด๋ฉด ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜
App.addOnKeyDown(81, function (player) {
	App.clearChat();
});

getPlayerByID

App.getPlayerByID(playerID: string);

id ์— ํ•ด๋‹นํ•˜๋Š” ํ”Œ๋ ˆ์ด์–ด๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

์˜ˆ์ œ

App.getPlayerByID ์‚ฌ์šฉ ๋ฐฉ๋ฒ•

// q ํ‚ค๋ฅผ ๋ˆ„๋ฅด๋ฉด ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜
App.addOnKeyDown(81, function (player) {
	const myPlayer = App.getPlayerByID(player.id);
});

๐Ÿ”‰ Sound Methods

Sound ํ•จ์ˆ˜ ํ•œ ๋ˆˆ์— ๋ณด๊ธฐ

// ๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ ์‚ฌ์šด๋“œ๋ฅผ ์žฌ์ƒ
App.playSound(fileName: string, loop: boolean = false, overlap: boolean = false)

// ๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ ๋งํฌ์— ํ•ด๋‹นํ•˜๋Š” ์‚ฌ์šด๋“œ๋ฅผ ์žฌ์ƒ
App.playSoundLink(link: string, loop: boolean = false)

// ๋ชจ๋“  ์žฌ์ƒ๋˜๋Š” ์‚ฌ์šด๋“œ๋ฅผ ๋ฉˆ์ถค
App.stopSound()

// ์ฐŒ๋ฅด๊ธฐ(Zํ‚ค) ๊ณต๊ฒฉ ํšจ๊ณผ์Œ์„ ๋ณ€๊ฒฝํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
App.changeAttackSound(fileName:string)

playSound

App.playSound(fileName: string, loop: boolean = false, overlap: boolean = false)

๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ ์‚ฌ์šด๋“œ๋ฅผ ์žฌ์ƒํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

fileName

String

๋ถˆ๋Ÿฌ์˜ฌ ํŒŒ์ผ์˜ ์ด๋ฆ„

loop

boolean

true: ๋ฐ˜๋ณต ์žฌ์ƒ false: 1ํšŒ ์žฌ์ƒ

overlap

boolean

์‚ฌ์šด๋“œ ์˜ค๋ฒ„๋žฉ(๊ฒน์นจ) ์žฌ์ƒ ๊ฐ€๋Šฅ ์—ฌ๋ถ€

์˜ˆ์ œ

ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ž…์žฅํ•  ๋•Œ ์ž…์žฅ์Œ ์ ์šฉํ•ด๋ณด๊ธฐ ( ํŒŒ์ผ )

//ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ž…์žฅํ•  ๋•Œ ์‹คํ–‰
App.onJoinPlayer.Add(function (player) {
	App.playSound("join.mp3", false, true);
});

App.playSoundLink(link: string, loop: boolean = false)

๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ ์‚ฌ์šด๋“œ๋ฅผ ์žฌ์ƒํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

๐Ÿ’ก ์˜ฌ๋ฐ”๋ฅธ ๋งํฌ๋ฅผ ์ž…๋ ฅํ–ˆ๋Š”๋ฐ ์žฌ์ƒ์ด ๋˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ

CORS ์ •์ฑ…์„ ์œ„๋ฐ˜ํ•œ ๊ฒฝ์šฐ์ผ ๊ฐ€๋Šฅ์„ฑ์ด ๋†’์Šต๋‹ˆ๋‹ค. CORS ์ •์ฑ…์„ ๋งž์ถœ ์ˆ˜ ์—†๋Š” ๊ฒฝ์šฐ์—๋Š” playSoundLink ๋Œ€์‹  ์Œ์•… ํŒŒ์ผ์„ ์—…๋กœ๋“œ ํ•˜์—ฌ playSound ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

link

String

์‚ฌ์šด๋“œ url

loop

boolean

true: ๋ฐ˜๋ณต ์žฌ์ƒ false: 1ํšŒ ์žฌ์ƒ

์˜ˆ์ œ

ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ž…์žฅํ•  ๋•Œ ์ž…์žฅ์Œ ์ ์šฉํ•ด๋ณด๊ธฐ ( ์‚ฌ์šด๋“œ url )

// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ž…์žฅํ•  ๋•Œ ์‹คํ–‰
App.onJoinPlayer.Add(function (player) {
	App.playSoundLink("https://zep.us/assets/sounds/ring.mp3",false);
});

stopSound

App.stopSound();

์žฌ์ƒ๋˜๊ณ  ์žˆ๋Š” ์‚ฌ์šด๋“œ๋ฅผ ๋ฉˆ์ถ”๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

  • ์—†์Œ

์˜ˆ์ œ

q๋ฅผ ๋ˆ„๋ฅด๋ฉด ์‚ฌ์šด๋“œ๊ฐ€ ๋ฉˆ์ถ”๋Š” ๊ธฐ๋Šฅ ๋งŒ๋“ค์–ด๋ณด๊ธฐ

// q ํ‚ค๋ฅผ ๋ˆ„๋ฅด๋ฉด ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜
App.addOnKeyDown(81,function(p){
	App.stopSound();
})

changeAttackSound

App.changeAttackSound(fileName:string)

์ฐŒ๋ฅด๊ธฐ(Zํ‚ค) ๊ณต๊ฒฉ ํšจ๊ณผ์Œ์„ ๋ณ€๊ฒฝํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

fileName

String

์ ์šฉํ•  ์‚ฌ์šด๋“œ ํŒŒ์ผ๋ช…

์˜ˆ์ œ

changeAttackSound ์‚ฌ์šฉ ๋ฐฉ๋ฒ•

App.onStart.Add(function(){
	App.changeAttackSound("attack.mp3");
})

๐Ÿ“ก ํ†ต์‹  Methods

ํ†ต์‹  ํ•จ์ˆ˜ ํ•œ ๋ˆˆ์— ๋ณด๊ธฐ

// ํ•ด๋‹น URL์— HTTP Get ์š”์ฒญ์„ ์‹คํ–‰
App.httpGet(url: string, headers: object, callback: ((string) => void))

// ํ•ด๋‹น URL์— HTTP Post ํฌ์ŠคํŒ…์„ ์‹คํ–‰
App.httpPost(url: string, headers: object, body: object, callback: ((string) => void))

// ํ•ด๋‹น URL์— HTTP Post ํฌ์ŠคํŒ…์„ ์‹คํ–‰
App.httpPostJson(url: string, headers: object, body: object, callback: ((string) => void))

httpGet

App.httpGet(url: string, headers: object, function(res: string){})

http get ์š”์ฒญ์„ ๋ณด๋‚ด๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

url

String

์š”์ฒญ์„ ๋ณด๋‚ผ ์ฃผ์†Œ

headers

Object

์š”์ฒญ ํ—ค๋”

res

String

์š”์ฒญ์— ๋Œ€ํ•œ ์‘๋‹ต

์˜ˆ์ œ

ํ•œ๊ตญ์–ด ๋ณ„๋ช… ์ƒ์„ฑ๊ธฐ API๋ฅผ ์ด์šฉํ•ด ์ž…์žฅํ•˜๋Š” ํ”Œ๋ ˆ์ด์–ด์˜ ๋‹‰๋„ค์ž„์„ ๋ฐ”๊ฟ”๋ณด๊ธฐ

// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ž…์žฅํ•  ๋•Œ ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜
App.onJoinPlayer.Add(function (player) {
	App.httpGet(
		"https://nickname.hwanmoo.kr/?format=json&count=1&max_length=6&whitespace=_",
		null,
		function (res) {
			// ์‘๋‹ต ๊ฒฐ๊ณผ๋ฅผ JSON ์˜ค๋ธŒ์ ํŠธ๋กœ ๋ณ€๊ฒฝ
			let response = JSON.parse(res);
			player.name = response.words[0];
			player.sendUpdated();
		}
	);
});

httpPost

App.httpPost(url: string, headers: object, body: object, function(res: string))

Form-Data ํ˜•ํƒœ์˜ http post ์š”์ฒญ์„ ๋ณด๋‚ด๋Š” ํ•จ์ˆ˜ ์ž…๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

url

String

์š”์ฒญ์„ ๋ณด๋‚ผ ์ฃผ์†Œ

headers

Object

์š”์ฒญ ํ—ค๋”, ์š”์ฒญ ํ—ค๋”๊ฐ€ ์—†์œผ๋ฉด { } ๋ฅผ ์ž…๋ ฅ.

body

Object

์š”์ฒญ ๋ฐ”๋”” ( Form data )

res

String

์š”์ฒญ์— ๋Œ€ํ•œ ์‘๋‹ต

์˜ˆ์ œ

์•ฑ์—์„œ ๋ณด๋‚ธ ํ—ค๋”์™€ ๋ฐ์ดํ„ฐ๋ฅผ ์‘๋‹ต์œผ๋กœ ๋ฐ›์•„ ์ฑ„ํŒ…์ฐฝ์— ์ถœ๋ ฅํ•ด๋ณด๊ธฐ.

์˜ˆ์ œ์™€ ๊ฐ™์ด key, value ๊ฐ’์„ string ํ˜•ํƒœ๋กœ ์ž‘์„ฑํ•ด์•ผํ•˜๋ฉฐ, ์š”์ฒญ ์„œ๋ฒ„์—์„œ ํผ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„ ์ฒ˜๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.

// q๋ฅผ ๋ˆŒ๋ €์„ ๋•Œ ์‹คํ–‰๋˜๋Š” ํ•จ์ˆ˜
App.addOnKeyDown(81, function (player) {
	App.httpPost(
		"https://postman-echo.com/post",
		{
			"test-header": "zep",
		},
		{
			"name": "zepscript",
		},
		(res) => {
			// ์š”์ฒญ ๊ฒฐ๊ณผ๋ฅผ JSON ์˜ค๋ธŒ์ ํŠธ๋กœ ๋ณ€ํ™˜
			let response = JSON.parse(res);
			App.sayToAll(`๋ณด๋‚ธ ํ—ค๋”: ${response.headers["test-header"]}`, 0xffffff);
			App.sayToAll(`๋ณด๋‚ธ ๋ฐ์ดํ„ฐ: ${response.form.name}`, 0xffffff);
		}
	);
});

httpPostJson

App.httpPostJson(url: string, headers: object, body: object, function(res: string))

Json ํ˜•ํƒœ์˜ http post ์š”์ฒญ์„ ๋ณด๋‚ด๋Š” ํ•จ์ˆ˜ ์ž…๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„
ํƒ€์ž…
์„ค๋ช…

url

String

์š”์ฒญ์„ ๋ณด๋‚ผ ์ฃผ์†Œ

headers

Object

์š”์ฒญ ํ—ค๋”, ์š”์ฒญ ํ—ค๋”๊ฐ€ ์—†์œผ๋ฉด { } ๋ฅผ ์ž…๋ ฅ.

body

Object

์š”์ฒญ ๋ฐ”๋”” ( JSON data )

res

String

์š”์ฒญ์— ๋Œ€ํ•œ ์‘๋‹ต

์˜ˆ์ œ

์•ฑ์—์„œ ๋ณด๋‚ธ ๋ฐ์ดํ„ฐ๋ฅผ ์‘๋‹ต์œผ๋กœ ๋ฐ›์•„ ์ฑ„ํŒ…์ฐฝ์— ์ถœ๋ ฅํ•ด๋ณด๊ธฐ.

// q๋ฅผ ๋ˆŒ๋ €์„ ๋•Œ ์‹คํ–‰๋˜๋Š” ํ•จ์ˆ˜
App.addOnKeyDown(81, function (player) {
	App.httpPostJson(
		"https://postman-echo.com/post",
		{},
		{
			name: "zepscript",
		},
		(res) => {
			App.sayToAll(`${res}`, 0xffffff);
			// ์š”์ฒญ ๊ฒฐ๊ณผ๋ฅผ JSON ์˜ค๋ธŒ์ ํŠธ๋กœ ๋ณ€ํ™˜
			let response = JSON.parse(res);
			App.sayToAll(`๋ณด๋‚ธ ๋ฐ์ดํ„ฐ: ${response.data.name}`, 0xffffff);
		}
	);
});

๐Ÿ’  ๊ณตํ†ต Methods

๊ณตํ†ต ํ•จ์ˆ˜ ํ•œ ๋ˆˆ์— ๋ณด๊ธฐ

// App ๊ด€๋ จ ํ•„๋“œ๊ฐ’์ด ๋ณ€๊ฒฝ๋˜๋ฉด ๋ณ€๊ฒฝ๊ฐ’์„ ์ ์šฉํ•จ
App.sendUpdated()

sendUpdated

App.sendUpdated()

App ๊ด€๋ จ ํ•„๋“œ ๊ฐ’์ด ๋ณ€๊ฒฝ๋˜๋ฉด ๋ณ€๊ฒฝ ๊ฐ’์„ ์ ์šฉํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

  • ์—†์Œ

Last updated