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

좜λ ₯ν•  κΈ€μ”¨μ˜ 색 (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

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

λ©”μ‹œμ§€κ°€ 좜λ ₯λ˜λŠ” 라벨의 배경색 값을 μž…λ ₯ν•˜μ§€ μ•Šμ„ 경우, 검은색(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

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

μ±„νŒ…μ°½μ— text λ‚΄μš©μ„ 좜λ ₯ν•©λ‹ˆλ‹€.

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

μ΄λ¦„νƒ€μž…μ„€λͺ…

text

String

μ±„νŒ…μ°½μ— 좜λ ₯ν•  ν…μŠ€νŠΈ

color

Uint

좜λ ₯ν•  κΈ€μ”¨μ˜ 색을 μ§€μ •ν•©λ‹ˆλ‹€. (HexCode) 값을 μž…λ ₯ν•˜μ§€ μ•Šμ„ 경우, 흰색(0xFFFFFF)으둜 μ μš©λ©λ‹ˆλ‹€. βž‘οΈκ΅¬κΈ€ 색상 선택 도ꡬ

예제

μž…μž₯λ©”μ‹œμ§€λ₯Ό ν•˜λŠ˜μƒ‰μœΌλ‘œ 좜λ ₯해보기

// ν”Œλ ˆμ΄μ–΄κ°€ μž…μž₯ν•  λ•Œ μ‹€ν–‰
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

좜λ ₯ν•  κΈ€μ”¨μ˜ 색을 μ§€μ •ν•©λ‹ˆλ‹€. (HexCode) 값을 μž…λ ₯ν•˜μ§€ μ•Šμ„ 경우, 흰색(0xFFFFFF)으둜 μ μš©λ©λ‹ˆλ‹€. βž‘οΈκ΅¬κΈ€ 색상 선택 도ꡬ

예제

μž…μž₯λ©”μ‹œμ§€λ₯Ό ν•˜λŠ˜μƒ‰μœΌλ‘œ 좜λ ₯해보기

// ν”Œλ ˆμ΄μ–΄κ°€ μž…μž₯ν•  λ•Œ μ‹€ν–‰
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