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
์คํ๋ผ์ดํธ ์ํธ ๊ทธ๋ฆผ ํ์ผ์ ์ฝ์ด ๊ฐ์ฒดํํ๋ ํจ์์ ๋๋ค.
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
๋ชจ๋ ํ๋ ์ด์ด์๊ฒ ์ง์ ๋ ์์น์ text๋ฅผ 3์ด๊ฐ ํ์ํ๋ ํจ์์ ๋๋ค.
ํ๋ผ๋ฏธํฐ
text
String
๋ผ๋ฒจ์ ์ถ๋ ฅํ ํ ์คํธ
color
Uint
์ถ๋ ฅํ ๊ธ์จ์ ์ (HexCode) ๊ฐ์ ์ ๋ ฅํ์ง ์์ ๊ฒฝ์ฐ, ํฐ์(0xFFFFFF)์ผ๋ก ์ ์ฉ๋ฉ๋๋ค. โก๏ธ๊ตฌ๊ธ ์์ ์ ํ ๋๊ตฌ
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
๋ชจ๋ ํ๋ ์ด์ด์๊ฒ ์ง์ ๋ ์์น์ text๋ฅผ 3์ด๊ฐ ํ์ํ๋ ํจ์์ ๋๋ค.
text ๋ถ๋ถ์ span
ํ๊ทธ๋ฅผ ๋ฃ์ด ํ
์คํธ๋ฅผ ๊พธ๋ฐ ์ ์์ต๋๋ค.
ํ๋ผ๋ฏธํฐ
text
String
๋ผ๋ฒจ์ ์ถ๋ ฅํ ํ ์คํธ ( span ํ๊ทธ ํ์ฉ )
color
Uint
์ถ๋ ฅํ ๊ธ์จ์ ์ (HexCode) ๊ฐ์ ์ ๋ ฅํ์ง ์์ ๊ฒฝ์ฐ, ํฐ์(0xFFFFFF)์ผ๋ก ์ ์ฉ๋ฉ๋๋ค.
bgColor
Uint
๋ฉ์์ง๊ฐ ์ถ๋ ฅ๋๋ ๋ผ๋ฒจ์ ๋ฐฐ๊ฒฝ์ ๊ฐ์ ์ ๋ ฅํ์ง ์์ ๊ฒฝ์ฐ, ๊ฒ์์(0x000000)์ผ๋ก ์ ์ฉ๋ฉ๋๋ค. โก๏ธ๊ตฌ๊ธ ์์ ์ ํ ๋๊ตฌ
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
์ฑํ ์ฐฝ์ text ๋ด์ฉ์ ์ถ๋ ฅํฉ๋๋ค.
ํ๋ผ๋ฏธํฐ
text
String
์ฑํ ์ฐฝ์ ์ถ๋ ฅํ ํ ์คํธ
color
Uint
์ถ๋ ฅํ ๊ธ์จ์ ์์ ์ง์ ํฉ๋๋ค. (HexCode) ๊ฐ์ ์ ๋ ฅํ์ง ์์ ๊ฒฝ์ฐ, ํฐ์(0xFFFFFF)์ผ๋ก ์ ์ฉ๋ฉ๋๋ค. โก๏ธ๊ตฌ๊ธ ์์ ์ ํ ๋๊ตฌ
์์
์ ์ฅ๋ฉ์์ง๋ฅผ ํ๋์์ผ๋ก ์ถ๋ ฅํด๋ณด๊ธฐ

// ํ๋ ์ด์ด๊ฐ ์
์ฅํ ๋ ์คํ
App.onJoinPlayer.Add(function (player) {
App.sayToAll(`[info]${player.name} has entered.`, 0x00ffff); // ํ๋์์ผ๋ก ํ์ํ๊ธฐ
});
sayToStaffs
Staff์ด์ ๊ถํ์ ์ ์ ์ฑํ ์ฐฝ์ text ๋ด์ฉ์ ์ถ๋ ฅํฉ๋๋ค.
ํ๋ผ๋ฏธํฐ
text
String
์ฑํ ์ฐฝ์ ์ถ๋ ฅํ ํ ์คํธ
color
Uint
์ถ๋ ฅํ ๊ธ์จ์ ์์ ์ง์ ํฉ๋๋ค. (HexCode) ๊ฐ์ ์ ๋ ฅํ์ง ์์ ๊ฒฝ์ฐ, ํฐ์(0xFFFFFF)์ผ๋ก ์ ์ฉ๋ฉ๋๋ค. โก๏ธ๊ตฌ๊ธ ์์ ์ ํ ๋๊ตฌ
์์
์ ์ฅ๋ฉ์์ง๋ฅผ ํ๋์์ผ๋ก ์ถ๋ ฅํด๋ณด๊ธฐ

// ํ๋ ์ด์ด๊ฐ ์
์ฅํ ๋ ์คํ
App.onJoinPlayer.Add(function (player) {
App.sayToStaffs(`[Staff] ${player.name} has entered.`, 0x00ffff); // ํ๋์์ผ๋ก ํ์ํ๊ธฐ
});
showWidget
๋ชจ๋ ํ๋ ์ด์ด์๊ฒ ์ง์ ๋ 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
๋งํฌ์ ํด๋นํ๋ 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
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
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
๋ฏธ๋๊ฒ์ ์ฑ์ ๊ฐ์ ์ข ๋ฃํ๋ ํจ์์ ๋๋ค.
์์
๋ฏธ๋๊ฒ์ ์ฑ์ ๊ฐ์ ์ข ๋ฃ์ํค๊ธฐ
// q ํค๋ฅผ ๋๋ฅด๋ฉด ๋์ํ๋ ํจ์
App.addOnKeyDown(81, function (player) {
App.forceDestroy();
});

clearChat
๋ชจ๋ ์ฑํ ๋ด์ฉ์ ์ญ์ ํ๋ ํจ์์ ๋๋ค.
์์
Q๋ฅผ ๋๋ฌ ์ฑํ ๋ด์ฉ ์ง์ฐ๊ธฐ
// q ํค๋ฅผ ๋๋ฅด๋ฉด ๋์ํ๋ ํจ์
App.addOnKeyDown(81, function (player) {
App.clearChat();
});

getPlayerByID
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
๋ชจ๋ ํ๋ ์ด์ด์๊ฒ ์ฌ์ด๋๋ฅผ ์ฌ์ํ๋ ํจ์์ ๋๋ค.
ํ๋ผ๋ฏธํฐ
fileName
String
๋ถ๋ฌ์ฌ ํ์ผ์ ์ด๋ฆ
loop
boolean
true: ๋ฐ๋ณต ์ฌ์ false: 1ํ ์ฌ์
overlap
boolean
์ฌ์ด๋ ์ค๋ฒ๋ฉ(๊ฒน์นจ) ์ฌ์ ๊ฐ๋ฅ ์ฌ๋ถ
์์
ํ๋ ์ด์ด๊ฐ ์ ์ฅํ ๋ ์ ์ฅ์ ์ ์ฉํด๋ณด๊ธฐ ( ํ์ผ )
//ํ๋ ์ด์ด๊ฐ ์
์ฅํ ๋ ์คํ
App.onJoinPlayer.Add(function (player) {
App.playSound("join.mp3", false, true);
});
playSoundLink
๋ชจ๋ ํ๋ ์ด์ด์๊ฒ ์ฌ์ด๋๋ฅผ ์ฌ์ํ๋ ํจ์์ ๋๋ค.
๐ก ์ฌ๋ฐ๋ฅธ ๋งํฌ๋ฅผ ์ ๋ ฅํ๋๋ฐ ์ฌ์์ด ๋์ง ์๋ ๊ฒฝ์ฐ
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
์ฌ์๋๊ณ ์๋ ์ฌ์ด๋๋ฅผ ๋ฉ์ถ๋ ํจ์์ ๋๋ค.
ํ๋ผ๋ฏธํฐ
์์
์์
q๋ฅผ ๋๋ฅด๋ฉด ์ฌ์ด๋๊ฐ ๋ฉ์ถ๋ ๊ธฐ๋ฅ ๋ง๋ค์ด๋ณด๊ธฐ
// q ํค๋ฅผ ๋๋ฅด๋ฉด ๋์ํ๋ ํจ์
App.addOnKeyDown(81,function(p){
App.stopSound();
})
changeAttackSound
์ฐ๋ฅด๊ธฐ(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
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
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
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 ๊ด๋ จ ํ๋ ๊ฐ์ด ๋ณ๊ฒฝ๋๋ฉด ๋ณ๊ฒฝ ๊ฐ์ ์ ์ฉํ๋ ํจ์์ ๋๋ค.
ํ๋ผ๋ฏธํฐ
์์
Last updated
Was this helpful?