# GDevelop

GDevelop 5용 **ZokoGames** 확장(`ZokoGames.json`)은 `packages/sdk-engines/gdevelop`에 있습니다. 일반 이벤트 확장이며 모든 액션, 조건, 표현식이 작은 JavaScript 코드 이벤트라서 별도 파일 없이 미리보기와 모든 웹 내보내기에서 동작합니다. "midgame", "rewarded" 같은 용어는 [용어집](https://docs.zokogames.com/kr/getting-started/glossary)에 있습니다.

> [!NOTE]
> 플러그인 1.7.2. 2026-11-23에 GDevelop 5.6.287로 검증했습니다. 확장 파일은 GDevelop 웹 에디터에서 오류 없이 가져와지고, GDevelop 자체 내보내기로 만든 예제의 HTML5 내보내기는 프로덕션 검사를 통과합니다. 에디터의 미리보기 버튼과 이벤트 시트 직접 편집은 해 보지 않았습니다. 문제가 있으면 GDevelop 버전과 정확한 오류를 [지원](https://docs.zokogames.com/kr/business/support)으로 보내 주세요.

## 설치 {#install}

GDevelop 확장을 내려받으세요: [/sdk-engines/zokogames-gdevelop-1.7.2.zip](https://www.zokogames.com/sdk-engines/zokogames-gdevelop-1.7.2.zip). 저장소의 `gdevelop` 폴더에서 빌드한 `ZokoGames.json`, 예제 프로젝트, README, 변경 기록이 들어 있습니다.

[/sdk-engines/gdevelop.zip](https://www.zokogames.com/sdk-engines/gdevelop.zip)은 항상 최신 버전입니다. 체크섬: [`/sdk-engines/SHA256SUMS`](https://www.zokogames.com/sdk-engines/SHA256SUMS). 모든 엔진 패키지의 버전, 크기, SHA-256 목록: [`/sdk-engines/engines.json`](https://www.zokogames.com/sdk-engines/engines.json).

1. 내려받은 파일의 압축을 푸세요. GDevelop에서 **Project manager**를 열고 **Extensions > Import extension**을 선택해 **`ZokoGames.json`**(zip이 아닙니다)을 고르세요.
2. 이벤트 에디터의 **ZokoGames** 아래에 액션, 조건, 표현식이 나타납니다. 표현식은 `ZokoGames::UserName()`처럼 씁니다.
3. 첫 씬의 시작에서 **Initialize** 액션을 실행하세요. 확장이 `https://sdk.zokogames.com/zokogames-sdk-v1.js`를 페이지에 직접 추가하므로 내보내기 파일을 수정할 필요가 없습니다.
4. HTML5로 내보내 zip을 업로드하세요.

먼저 동작을 보려면 내려받은 파일의 `examples/zokogames-example/game.json`을 열어 미리보기를 실행하세요. 화면의 텍스트가 각 검사를 나열합니다.

## 어떤 경로를 따를까

| 해당하는 경우 | 할 일 |
| --- | --- |
| 완성된 게임이 있는 GDevelop 제작자 | 확장을 가져오고 **Initialize**와 아래 광고 이벤트를 추가한 뒤 HTML5로 내보내 업로드하세요. JavaScript는 필요 없습니다. |
| JavaScript 이벤트에 익숙한 경우 | **Initialize**가 끝난 뒤에는 JavaScript 코드 이벤트에서 같은 SDK를 `window.ZokoGames.SDK`로 쓸 수 있습니다. |

## 태그, 결과, 오류 {#tags-results-and-errors}

<!-- search: headings-only -->

모든 비동기 액션은 **Tag**를 가장 먼저 받습니다. 호출이 끝나면 해당 태그의 **On request completed** 또는 **On request failed**가 한 프레임 동안 true가 되고, **On any request failed**는 모든 실패에서 true가 됩니다. 진행 중인 요청마다 태그를 하나씩 사용하세요.

GDevelop은 이 액션을 기다립니다. 같은 이벤트에서 그 뒤에 오는 액션과 하위 이벤트는 요청이 끝난 뒤에야 실행됩니다. 간단한 연쇄는 쉬워지지만(결과 표현식이 다음 액션에서 이미 새 값을 가집니다), 이벤트의 나머지가 기다리면 안 될 때는 광고 요청이나 느린 호출을 별도 이벤트에 두세요.

| 표현식 | 내용 |
| --- | --- |
| `ResultString` | 마지막 결과가 텍스트일 때의 값: 토큰, 초대 링크, 저장된 항목. |
| `ResultNumber` | 숫자로 본 마지막 결과(불리언은 1과 0이며, **Check ad blocker**는 차단되면 1로 설정합니다). |
| `ResultJSON` | JSON으로 본 마지막 결과(친구 목록 페이지, 계정 연결 응답). |
| `ErrorCode`, `ErrorMessage`, `ErrorContainerId` | 마지막 실패의 세부 정보. `ErrorContainerId`는 배너 오류에서 설정됩니다. `ErrorDescription(code)`는 코드의 영어 설명을 반환합니다. |

## 광고 중 게임을 자동으로 일시 중지하고 음소거합니다

광고가 시작되면 확장이 게임의 모든 소리를 즉시 음소거하고, **On ad started**를 한 프레임 실행한 뒤 게임을 일시 중지합니다. 광고가 끝나거나 실패하면 **On ad finished**나 **On ad error**가 실행되기 전에 게임을 재개하고 소리를 복원합니다. 게임이 직접 건 일시 중지는 건드리지 않습니다. 게임에서 직접 처리한다면 **Pause the game during ads**와 **Mute the game during ads**로 각각 끌 수 있습니다. 게임 소리는 기본적으로 포털의 음소거 설정도 따릅니다(**Follow the portal mute setting**).

## 동작하는 이벤트 모음 {#a-working-set-of-events}

아래 이벤트는 초기화, 미드게임 광고, 보상형 광고, 게임플레이 시작과 중지, 저장과 불러오기, 리더보드 점수를 다룹니다. 씬 변수 `Coins`, `Best`, `RewardPending`을 사용하세요.

```
At the beginning of the scene (first scene)
    -> ZokoGames: Initialize (tag "init")

ZokoGames: On request completed ("init")
    -> ZokoGames: Get saved item (tag "load", key "best")
       ZokoGames: Loading stop (tag "ls")
    sub-event: ZokoGames::HasSavedItem("best") = 1
       -> Change Best: set to ToNumber(ZokoGames::SavedItem("best"))
ZokoGames: On request failed ("init")              // SDK missing or blocked: just start
    -> Change the scene to "Menu"

// Ads: the extension pauses and mutes; grant the reward only in On ad finished
ZokoGames: On ad finished
    + RewardPending = 1
    -> Add 10 to Coins ; Set RewardPending to 0
ZokoGames: On ad error
    -> Set RewardPending to 0

// Gameplay start/stop
Game scene: At the beginning of the scene (player can act)
    + ZokoGames: Is available
    -> ZokoGames: Gameplay start (tag "gs")
Game over (or pause menu opened)
    + ZokoGames: Is available
    -> ZokoGames: Gameplay stop (tag "gx")

// Midgame ad at a natural break, in its own event
Game over screen: At the beginning of the scene
    + ZokoGames: Is available
    -> ZokoGames: Request ad (type midgame, tag "mid")

// Rewarded ad
Reward button is clicked
    + ZokoGames: Is available
    -> Set RewardPending to 1 ; ZokoGames: Request ad (type rewarded, tag "rew")

// Save
Round ends and Score > Best
    -> Set Best to Score ; ZokoGames: Set saved item (tag "save", key "best", value ToString(Best))

// Leaderboard (signed-in players only; board enabled in the console)
Round ends
    + ZokoGames: Is available
    -> ZokoGames: Submit score (tag "score", encrypted "", score Score)
```

이 이벤트에는 의도적으로 함정 두 가지가 들어 있습니다.

- **On request completed ("rew")는 "광고 완료"가 아닙니다.** 광고가 채워지지 않았거나 차단되었거나 쿨다운 중이면 SDK는 **On ad error**를 전달하고 액션은 그래도 완료되므로, 보상은 **On ad finished**에서만 지급하세요. SDK가 비활성화되어 있으면 액션이 실패하고(**On request failed**) 광고 이벤트는 둘 다 발생하지 않습니다. 게임은 일시 중지된 적이 없으므로 재개할 것도 없습니다.
- **`encrypted` 값이 빈 `Submit score`는** 암호화 키가 없는 보드에서만 동작합니다(평문 점수가 보드 규칙에 따라 검증됩니다). 키가 있는 보드는 올바르게 암호화된 페이로드만 인정하며([리더보드](https://docs.zokogames.com/kr/sdk/leaderboards#client-submission)), 확장에는 암호화 도우미가 없습니다. 점수를 서버에서 계산해 서버 API를 사용하거나, 캐주얼 게임이라면 보드에 키를 두지 마세요. 로그인하지 않은 플레이어는 순위에 오르지 않습니다.

### 구매

```
ZokoGames: On request completed ("init") + ZokoGames: Is store available
    -> Show the shop button ; ZokoGames: Get catalogue items (limit 50, offset 0, tag "cat")
ZokoGames: On request completed ("cat")
    -> Repeat ZokoGames::StoreItemCount() times: row with StoreItemName(i), StoreItemPrice(i), StoreItemCurrency(i)
Buy button is clicked
    -> ZokoGames: Buy item (ZokoGames::StoreItemSku(selected), tag "buy")
ZokoGames: On request completed ("buy")
    -> grant ZokoGames::PurchasedItemId() ; ZokoGames: Get purchase token (tag "tok")   // then send PurchaseToken to your server
ZokoGames: On request failed ("buy") + Last error is "purchaseCancelled"     -> (nothing)
ZokoGames: On request failed ("buy") + Last error is "userNotAuthenticated"  -> ZokoGames: Show login prompt (tag "login")
```

소유권은 서버에서 검증하세요([게임 내 구매](https://docs.zokogames.com/kr/sdk/purchases) 참고). `StoreItemPrice`는 가격이 없으면 -1이고, `InventoryQuantity`는 수량을 세지 않으면 -1입니다.

## 액션

<!-- search: headings-only -->

| 그룹 | 액션 |
| --- | --- |
| 시작 | **Initialize** |
| 광고 | **Request ad**(midgame 또는 rewarded), **Check ad blocker**, **Pause the game during ads**, **Mute the game during ads**, **Follow the portal mute setting** |
| 배너 | **Request banner**(id, 크기 728x90, 300x250, 320x50, 468x60 또는 320x100, x, y, 너비, 높이), **Request responsive banner**(id, x, y, 너비, 높이), **Clear banner**, **Clear all banners** |
| 게임 | **Gameplay start**, **Gameplay stop**, **Loading start**, **Loading stop**, **Report loading progress**(0~100), **Happytime**, **Report completed percentage**, **Set game context**(JSON), **Clear game context**, **Report chat message**, **Set screenshot provider**, **Answer screenshot** |
| 멀티플레이어 | **Update room**, **Set room public**, **Left room**, **Create invite link**, **Show invite button**과 **Hide invite button**(더 이상 권장되지 않음), **Show invite button (portal only)**와 **Hide invite button (portal only)**(SDK 1.7.0) |
| 사용자 | **Get user**, **List friends**, **Get user token**, **Show login prompt**, **Show account link prompt**, **Submit score** |
| 스토어 | **Get catalogue items**, **Get player inventory**, **Buy item**, **Consume item**, **Set sandbox**, **Get purchase token**, **Get payment provider user token**(더 이상 권장되지 않음) |
| 클라우드 저장 | **Get saved item**, **Set saved item**, **Remove saved item**, **Clear saved data**, **Mirror localStorage to cloud save**, **Stop mirroring localStorage** |
| 업적 | **Unlock achievement**(키), **List achievements** |
| 분석 | **Track event**(SDK 1.7.0), **Track order** |

배너 사각형은 왼쪽 위를 원점으로 하는 게임 해상도 픽셀(프로젝트 속성의 크기) 단위이며, 확장이 이를 크기 조정된 캔버스로 변환합니다. 배너는 메뉴 씬에서만 요청하세요.

## 조건

<!-- search: headings-only -->

- 상태: **Is initialized**, **Is available**(SDK가 비활성화되면 false), **Is QA tool**.
- 요청: **On request completed**, **On request failed**, **On any request failed**, **Last error is**(코드).
- 광고: **On ad started**, **On ad finished**, **On ad error**, **Is ad playing**.
- 설정: **On settings changed**, **Is mute requested**, **Is chat disabled**, **Is kids mode**.
- 오프라인: **On offline changed**, **Is offline**.
- 멀티플레이어: **Is instant multiplayer**, **On join room**.
- 업적: **On achievement unlocked**.
- 계정: **On auth changed**, **Is logged in**, **Is account available**.
- 스토어: **Is store available**.
- 스크린샷과 저장소 미러: **On screenshot requested**, **On mirror error**.

트리거("On ...")는 한 프레임 동안 true입니다. 같은 종류가 동시에 도착하면 두 번째는 다음 프레임에 전달되므로 하나도 사라지지 않습니다.

**키즈 모드.** 게임이 키즈 모드로 실행될 때(어린이용 플래그가 있는 게임, 또는 키즈 모드인 플레이어) **Is kids mode**(`KidsMode`) 값은 true입니다. 이때는 채팅, 룸, 로그인 안내, 상점 화면을 숨기세요. 이 필드를 보내지 않는 포털에서는 false가 되므로, **Is chat disabled**도 계속 따르세요. 테스트하려면 로컬 모드에서 페이지 주소에 `?kidsMode=true`를 추가하세요. [키즈 모드](https://docs.zokogames.com/kr/guides/kids-mode)를 참고하세요.

## 표현식

<!-- search: headings-only -->

`Environment`, `SdkVersion`, `GameId`, `MuteAudio`, `DisableChat`, `KidsMode`, `InviteParam(key)`, `InviteParamsJSON`, `UserName`, `UserPictureUrl`, `UserId`(서버에서는 절대 신뢰하지 말고 토큰을 검증하세요), `UserToken`, `FriendCount`, `FriendsTotal`, `FriendsHasMore`, `FriendName(i)`, `FriendId(i)`, `FriendPictureUrl(i)`, `Locale`, `CountryCode`, `DeviceType`, `SavedItem(key)`, `HasSavedItem(key)`, `ErrorCodes(module)`(`ad`, `banner`, `user`, `data`, `store`, `room`, `general`의 쉼표로 구분한 코드), `ErrorDescription(code)`, `ResultJSON`, `ResultString`, `ResultNumber`, `ErrorCode`, `ErrorMessage`, `ErrorContainerId`, `MirrorErrorCode`, `MirrorErrorMessage`, 스토어 표현식 `StoreItemCount`, `StoreItemSku(i)`, `StoreItemName(i)`, `StoreItemDescription(i)`, `StoreItemImageUrl(i)`, `StoreItemPrice(i)`, `StoreItemCurrency(i)`, `StoreItemConsumable(i)`, `InventoryCount`, `InventorySku(i)`, `InventoryName(i)`, `InventoryDescription(i)`, `InventoryImageUrl(i)`, `InventoryQuantity(i)`, `PurchasedItemId`, `PurchaseToken`, `XsollaUserToken`(구매 토큰의 예전 이름, 더 이상 권장되지 않음), 그리고 업적 표현식 `AchievementCount`, `AchievementKeyAt(i)`, `AchievementNameAt(i)`, `AchievementDescriptionAt(i)`, `AchievementPointsAt(i)`, `AchievementUnlockedAt(i)`, `AchievementIsUnlockedAt(i)`(1 또는 0), `LastUnlockReason`, `LastAchievementKey`, `LastAchievementName`, `LastAchievementPoints`가 있습니다. `...At(i)` 표현식을 쓰기 전에 **List achievements**를 실행하세요. **Unlock achievement**는 `LastAchievement...` 표현식을 채웁니다. 게스트와 알 수 없는 키에서도 액션은 완료되며 `LastUnlockReason`은 `guest`, `not_found`, `not_live`, `rate_limited`, `error` 중 하나입니다. [업적](https://docs.zokogames.com/kr/sdk/achievements)을 참고하세요.

`SavedItem(key)`는 **Initialize**가 완료된 뒤 SDK를 직접 읽으므로, 게임 어디에서 저장한 값이든 바로 보입니다.

## JavaScript 이벤트

```js
// JavaScript code event, after the "init" request completed.
const SDK = window.ZokoGames.SDK;
SDK.user.getUser().then((user) => {
  runtimeScene.getVariables().get("PlayerName").setString(user ? user.username : "guest");
});
```

## 방 데이터 채널

SDK 1.3.0에서 추가되었습니다. 방 데이터 채널을 사용하면 한 방의 플레이어끼리 작은 JSON 메시지를 주고받고, 호스트만 쓸 수 있는 작은 상태를 공유할 수 있어서 간단한 멀티플레이어 게임에 자체 서버가 필요 없습니다. 텍스트 채팅이 아니라 게임 데이터를 위한 것입니다. 채널은 **Update room** 이후(또는 초대를 통해 참여한 뒤)에 생기고 **Left room**으로 끝나며, 로그인한 플레이어와 실시간 기능이 켜진 포털이 필요합니다(그렇지 않으면 `roomUnavailable`). 한도는 다음과 같습니다. 메시지 또는 패치당 8 KB, 초당 메시지 20개, 상태 64 KB, 상태 키는 `A-Z a-z 0-9 _ . : -` 문자 1~40자. 포털에서 메시지는 보낸 사람에게 되돌아오지 않으며, 방의 첫 번째 플레이어가 호스트입니다. 전체 규칙과 오류 코드(`notInRoom`, `notHost`, `payloadTooLarge`, `stateTooLarge`, `unknownMember`, `rateLimited`, `roomUnavailable`)는 [game 모듈](https://docs.zokogames.com/kr/sdk/game#room-data-channel)과 [멀티플레이어 가이드](https://docs.zokogames.com/kr/guides/multiplayer-invites#6-exchange-game-data-in-the-room)에 있습니다.

메시지와 값 파라미터는 텍스트를 받습니다. 올바른 JSON(`{"x":1}`, `5`, `true`)은 그 JSON 값으로 전송되고, 그 외에는 일반 텍스트로 전송됩니다. `localhost`에서는 SDK의 로컬 모드가 같은 방 id에 참여한 두 브라우저 탭을 두 명의 플레이어처럼 동작하게 합니다.

| 종류 | 함수 |
| --- | --- |
| 액션 | **Send room message**(tag, data), **Send room message to member**(tag, member id, data), **Set room state key**(tag, key, value, 호스트만), **Remove room state key**(tag, key, 호스트만) |
| 트리거 | **On room message**, **On room state changed**, **On room members changed**, **On room host changed**, **On room left**(SDK 1.7.0), **On room error** |
| 조건 | **Is room host** |
| 메시지 표현식 | `RoomMessageData`, `RoomMessageFrom`, `RoomMessageDirect`, `RoomMessageSeq`, `RoomMessageValue(key)` |
| 상태 표현식 | `RoomStateJSON`, `RoomStateValue(key)`, `RoomStateChangedKeys`, `RoomStateChangedBy`, `RoomStateRev` |
| 멤버 표현식 | `RoomMemberCount`, `RoomMemberIdAt(i)`, `RoomMemberNameAt(i)`, `RoomMemberPictureUrlAt(i)`, `RoomHostId`, `RoomSelfId` |
| 퇴장 표현식 | `RoomLeftReason`(`left`, `kicked`, `closed`, `disconnected`), `RoomLeftRoomId`(**On room left**용, SDK 1.7.0) |
| 오류 표현식 | `RoomErrorCode`, `RoomErrorMessage`(방 오류 트리거용이며, 요청 실패는 여전히 **On request failed**를 사용) |

```
ZokoGames: On room host changed
  + ZokoGames: Is room host        -> ZokoGames: Set room state key (key "turn", value "X", tag "turn")
Cell is clicked                    -> ZokoGames: Send room message ("{""cell"":" + ToString(Cell) + "}", tag "move")
ZokoGames: On room message         -> place a mark at ZokoGames::RoomMessageValue("cell")
ZokoGames: On room state changed   -> Text: set to ZokoGames::RoomStateValue("turn")
```

## 웹에서 중요한 내보내기 설정 {#export-settings-that-matter-on-the-web}

- **HTML5로 내보내기**(로컬 폴더)를 선택하고, `index.html`이 압축 파일의 루트에 오도록 내보내기 폴더의 **내용물**을 zip으로 묶으세요.
- **사전 압축 금지.** GDevelop은 일반 파일 이름으로 요청하므로 내보낸 결과를 그대로 업로드하세요. 한도: 파일 1,500개, 압축 해제 시 250 MB, 최초 다운로드 약 50 MB(모바일은 20 MB). 이미지와 오디오를 압축하고 [첫 프레임을 빠르게](https://docs.zokogames.com/kr/guides/first-frame)를 참고하세요.
- **캔버스 크기.** 프레임 크기는 전체 화면과 회전에 따라 바뀝니다. 씬이 모든 [필수 해상도](https://docs.zokogames.com/kr/requirements/gameplay)에 맞도록 게임 해상도가 적응하게 설정하세요(Project properties > Resolution and rendering).
- **오디오 잠금 해제.** 브라우저는 첫 클릭이나 탭 전까지 오디오를 일시 중단 상태로 둡니다. 음악은 첫 씬 시작이 아니라 "탭하여 시작" 버튼에서 재생하세요.
- **전체 화면.** 포털 프레임 바의 전체 화면 버튼을 사용하는 것이 좋습니다. 경쟁하는 버튼은 추가하지 마세요.
- **로딩.** 첫 씬에서 **Loading start**를 실행하고, 리소스를 불러오는 동안 **Report loading progress**를, 플레이를 시작할 수 있으면 **Loading stop**을 실행하세요.

## 채팅 신고, 스크린샷, 저장소 미러

SDK 1.4.0부터: 액션 **Report chat message**(이름, 메시지, 사유, 선택 사항인 사용자 id, 방 id, 컨텍스트 JSON), 조건 **On screenshot requested**와 함께 쓰는 액션 **Set screenshot provider**와 **Answer screenshot**, 조건 **On mirror error**와 함께 쓰는 **Mirror localStorage to cloud save**가 있습니다. 스크린샷 제공자가 켜져 있고 게임이 1.5초 안에 응답하지 않으면 게임 캔버스가 전송됩니다. GDevelop의 **Storage** 액션은 데이터를 IndexedDB에 보관하므로 미러가 복사하지 않습니다. 그런 저장에는 클라우드 저장 액션을 사용하세요.

## SDK 1.7.0

- **Track event**(이름, params JSON): 보내고 잊기. 이름: 소문자로 시작하고 소문자, 숫자, 밑줄이 이어지며 최대 40자. params: 텍스트, 숫자, 예/아니오 값이 최대 10개인 선택적 평면 JSON 객체.
- `RoomLeftReason`과 `RoomLeftRoomId`가 있는 **On room left**: 게임이 요청하지 않았는데 포털이 플레이어의 방 멤버십을 끝냈습니다(추방, 방 닫힘, 연결 끊김). 호스트 플래그가 해제됩니다.
- **Show invite button (portal only)**와 **Hide invite button (portal only)**: 방의 참여 가능 여부를 바꾸지 않고 포털의 초대 버튼만 다룹니다. 링크는 `ResultString`에 있습니다.
- `data.mirrorIndexedDB`는 액션이 아닙니다. 게임이 파일을 읽기 전에 페이지에서 실행되어야 하므로, 게임을 불러오기 전에 페이지 스크립트에서 `ZokoSDK.data.mirrorIndexedDB`를 호출하세요.

## 광고 규칙 {#ad-rules}

프리롤은 없습니다. 게임이 시작되기 전에 광고를 요청할 수는 없습니다. 전면 광고 유형은 midgame뿐이므로, 다른 플랫폼의 전면 광고나 커머셜 브레이크는 midgame 광고가 됩니다(**Request ad**, 유형 `midgame`). 그 밖의 유형은 `rewarded`뿐입니다. 로컬 모드(포털 밖의 `localhost`에서 테스트하는 경우)에서는 게임이 **Gameplay start** 액션을 실행하거나 페이지가 화면에 보인 시간이 30초가 지나기 전까지 midgame 요청이 **On ad error**(`adCooldown`)로 실패합니다. 포털에서도 첫 midgame 광고에는 먼저 **Gameplay start** 액션 실행이 필요하므로, 플레이어가 조작을 시작할 때 호출하세요(호출하지 않는 게임은 플레이가 시작되고 30초 뒤에 midgame 광고가 나옵니다). 보상형 광고는 이 제한을 받지 않습니다. 자세한 내용: [광고 레퍼런스](https://docs.zokogames.com/kr/sdk/ads#gameplay-first)와 [광고 수익화 가이드](https://docs.zokogames.com/kr/guides/ad-monetisation).

## 로컬에서 테스트 {#test-locally}

별도의 시뮬레이터는 없습니다. 페이지의 호스트가 `localhost`, `127.0.0.1`, `*.localhost` 이름이면 JavaScript SDK가 자체 [로컬 모드](https://docs.zokogames.com/kr/getting-started/local-testing)로 실행됩니다. 광고마다 3초짜리 오버레이, 가짜 플레이어, `localStorage` 클라우드 저장, 항목 세 개짜리 테스트 스토어가 제공되어 포털과 같은 이벤트가 발생합니다. 그 외의 호스트에서는 환경이 `disabled`이고 **Is available**은 false입니다.

- GDevelop 미리보기는 작은 로컬 웹 서버에서 실행됩니다. 거기서 `Environment`가 `disabled`로 나오면(`localhost` 대신 네트워크 주소), 프로젝트를 내보내 `localhost`에서 폴더를 제공하거나 `?useLocalSdk=true`로 페이지를 여세요.
- 3분 안에 두 번째 midgame을 요청하면 `adCooldown`으로 실패합니다(**On ad error** 발생). 이것은 실제 규칙이므로 이벤트가 이를 처리해야 합니다.
- 유용한 스위치: `?sdk_debug=true`, `?ad_response=unfilled`, `?user_response=logged_out`.
- 그다음 로컬 주소로 [미리보기 도구](https://www.zokogames.com/kr/preview)를 열어 체크리스트 항목이 하나씩 통과하는지 확인하세요.

## API

### `init`

<!-- search: headings-only -->

| JavaScript | GDevelop |
| --- | --- |
| `init` | 액션 `Initialize`; 조건 `IsInitialized`, `IsAvailable` |
| `environment` | 표현식 `Environment` |
| `isQaTool` | 조건 `IsQaTool` |

### `ad.*`

<!-- search: headings-only -->

| JavaScript | GDevelop |
| --- | --- |
| `ad.requestAd` | 액션 `RequestAd`; 조건 `OnAdStarted`, `OnAdFinished`, `OnAdError`, `IsAdPlaying` |
| `ad.requestAd.adStarted` | 조건 `OnAdStarted`; `IsAdPlaying`이 true |
| `ad.requestAd.adFinished` | 조건 `OnAdFinished` |
| `ad.requestAd.adError` | 조건 `OnAdError`; 표현식 `ErrorCode` |
| `ad.hasAdblock` | 액션 `HasAdblock` |

### `banner.*`

<!-- search: headings-only -->

| JavaScript | GDevelop |
| --- | --- |
| `banner.requestBanner` | 액션 `RequestBanner` |
| `banner.requestResponsiveBanner` | 액션 `RequestResponsiveBanner` |
| `banner.clearBanner` | 액션 `ClearBanner` |
| `banner.clearAllBanners` | 액션 `ClearAllBanners` |

### `game.*`

<!-- search: headings-only -->

| JavaScript | GDevelop |
| --- | --- |
| `game.settings` | 표현식 `MuteAudio`, `DisableChat`, `KidsMode`; 조건 `IsMuteRequested`, `IsChatDisabled`, `IsKidsMode` |
| `game.addSettingsChangeListener` | 조건 `OnSettingsChanged` |
| `game.gameplayStart` | 액션 `GameplayStart` |
| `game.gameplayStop` | 액션 `GameplayStop` |
| `game.loadingStart` | 액션 `LoadingStart` |
| `game.loadingStop` | 액션 `LoadingStop` |
| `game.loadingProgress` | 액션 `LoadingProgress` |
| `game.happytime` | 액션 `Happytime` |
| `game.reportGameCompletedPercentage` | 액션 `ReportCompleted` |
| `game.reportChat` | 액션 `ReportChat` |
| `game.onScreenshotRequest` | 액션 `SetScreenshotProvider`, `AnswerScreenshot`; 조건 `OnScreenshotRequested` |
| `game.setGameContext` | 액션 `SetGameContext` |
| `game.clearGameContext` | 액션 `ClearGameContext` |
| `game.isInstantMultiplayer` | 조건 `IsInstantMultiplayer` |
| `game.isInstantJoin` | 조건 `IsInstantMultiplayer` |
| `game.isOffline` | 조건 `IsOffline` |
| `game.gameId` | 표현식 `GameId` |
| `game.addOfflineListener` | 조건 `OnOfflineChanged` |
| `game.updateRoom` | 액션 `UpdateRoom`; 액션 `SetRoomPublic` |
| `game.leftRoom` | 액션 `LeftRoom` |
| `game.addJoinRoomListener` | 조건 `OnJoinRoom` |
| `game.inviteParams` | 표현식 `InviteParamsJSON`, `InviteParam` |
| `game.inviteLink` | 액션 `InviteLink` |
| `game.getInviteParam` | 표현식 `InviteParam` |
| `game.showInviteButton` | 액션 `ShowInviteButton`; `ShowInviteButtonPortalOnly` (`{ portalOnly: true }`) |
| `game.hideInviteButton` | 액션 `HideInviteButton`; `HideInviteButtonPortalOnly` (`{ portalOnly: true }`) |
| `game.room` | 액션 `SendRoomMessage`, `SendRoomMessageTo`, `SetRoomStateKey`, `RemoveRoomStateKey`; 조건 `OnRoomMessage`, `OnRoomStateChanged`, `OnRoomMembersChanged`, `OnRoomHostChanged`, `OnRoomError`, `IsRoomHost` |
| `game.room.send` | 액션 `SendRoomMessage`, `SendRoomMessageTo` |
| `game.room.onMessage` | 조건 `OnRoomMessage`; 표현식 `RoomMessageData`, `RoomMessageFrom`, `RoomMessageDirect`, `RoomMessageSeq`, `RoomMessageValue` |
| `game.room.addMessageListener` | 조건 `OnRoomMessage` |
| `game.room.setState` | 액션 `SetRoomStateKey`, `RemoveRoomStateKey` |
| `game.room.getState` | 표현식 `RoomStateJSON`, `RoomStateValue` |
| `game.room.onState` | 조건 `OnRoomStateChanged`; 표현식 `RoomStateChangedKeys`, `RoomStateChangedBy`, `RoomStateRev` |
| `game.room.addStateListener` | 조건 `OnRoomStateChanged` |
| `game.room.members` | 표현식 `RoomMemberCount`, `RoomMemberIdAt`, `RoomMemberNameAt`, `RoomMemberPictureUrlAt` |
| `game.room.onMembers` | 조건 `OnRoomMembersChanged` |
| `game.room.addMembersListener` | 조건 `OnRoomMembersChanged` |
| `game.room.isHost` | 조건 `IsRoomHost` |
| `game.room.onHostChange` | 조건 `OnRoomHostChanged`; 표현식 `RoomHostId` |
| `game.room.addHostChangeListener` | 조건 `OnRoomHostChanged` |
| `game.room.selfId` | 표현식 `RoomSelfId` |
| `game.room.onError` | 조건 `OnRoomError`; 표현식 `RoomErrorCode`, `RoomErrorMessage` |
| `game.room.addErrorListener` | 조건 `OnRoomError` |
| `game.room.addLeftListener` | 조건 `OnRoomLeft`; 표현식 `RoomLeftReason`, `RoomLeftRoomId` |

### `user.*`

<!-- search: headings-only -->

| JavaScript | GDevelop |
| --- | --- |
| `user.isUserAccountAvailable` | 조건 `IsAccountAvailable` |
| `user.systemInfo` | 표현식 `Locale`, `CountryCode`, `DeviceType` |
| `user.getUser` | 액션 `GetUser`; 표현식 `UserName`, `UserPictureUrl`, `UserId`; 조건 `IsLoggedIn` |
| `user.listFriends` | 액션 `ListFriends`; 표현식 `FriendCount`, `FriendsTotal`, `FriendsHasMore`, `FriendName`, `FriendId`, `FriendPictureUrl` |
| `user.getUserToken` | 액션 `GetUserToken`; 표현식 `UserToken` |
| `user.showAuthPrompt` | 액션 `ShowAuthPrompt` |
| `user.addAuthListener` | 조건 `OnAuthChanged` |
| `user.showAccountLinkPrompt` | 액션 `ShowAccountLinkPrompt` |
| `user.submitScore` | 액션 `SubmitScore` |
| `user.getXsollaUserToken` | 액션 `GetXsollaUserToken`; 표현식 `XsollaUserToken` |

### `data.*`

<!-- search: headings-only -->

| JavaScript | GDevelop |
| --- | --- |
| `data.getItem` | 액션 `GetItem`; 표현식 `SavedItem`, `HasSavedItem` |
| `data.setItem` | 액션 `SetItem` |
| `data.removeItem` | 액션 `RemoveItem` |
| `data.clear` | 액션 `ClearData` |
| `data.mirrorLocalStorage` | 액션 `MirrorLocalStorage`, `StopMirrorLocalStorage`; 조건 `OnMirrorError`; 표현식 `MirrorErrorCode`, `MirrorErrorMessage` |

### `store.*`

<!-- search: headings-only -->

| JavaScript | GDevelop |
| --- | --- |
| `store.isAvailable` | 조건 `IsStoreAvailable` |
| `store.getCatalogItems` | 액션 `GetCatalogItems`; 표현식 `StoreItemCount`, `StoreItemSku`, `StoreItemName`, `StoreItemDescription`, `StoreItemImageUrl`, `StoreItemPrice`, `StoreItemCurrency`, `StoreItemConsumable` |
| `store.getPlayerInventory` | 액션 `GetPlayerInventory`; 표현식 `InventoryCount`, `InventorySku`, `InventoryName`, `InventoryDescription`, `InventoryImageUrl`, `InventoryQuantity` |
| `store.buyItem` | 액션 `BuyItem`; 표현식 `PurchasedItemId` |
| `store.consumeItem` | 액션 `ConsumeItem` |
| `store.getPurchaseToken` | 액션 `GetPurchaseToken`; 표현식 `PurchaseToken` |
| `store.setSandbox` | 액션 `SetSandbox` |

### `achievements.*`

<!-- search: headings-only -->

| JavaScript | GDevelop |
| --- | --- |
| `achievements.list` | 액션 `ListAchievements`; 표현식 `AchievementCount`, `AchievementKeyAt`, `AchievementNameAt`, `AchievementDescriptionAt`, `AchievementPointsAt`, `AchievementUnlockedAt`, `AchievementIsUnlockedAt` |
| `achievements.unlock` | 액션 `UnlockAchievement`; 표현식 `LastUnlockReason`, `LastAchievementKey`, `LastAchievementName`, `LastAchievementPoints` |
| `achievements.onUnlock` | 조건 `OnAchievementUnlocked` |

### `analytics.*`

<!-- search: headings-only -->

| JavaScript | GDevelop |
| --- | --- |
| `analytics.track` | 액션 `TrackEvent` |
| `analytics.trackOrder` | 액션 `TrackOrder` |

### `constants`

<!-- search: headings-only -->

| JavaScript | GDevelop |
| --- | --- |
| `ERROR_CODES` | 표현식 `ErrorCodes`; 조건 `LastErrorIs` |
| `ERROR_CODE_DESCRIPTIONS` | 표현식 `ErrorDescription` |
| `SDK_VERSION` | 표현식 `SdkVersion` |

## 알려진 함정

<!-- search: headings-only -->

- **가져오기 실패.** zip이 아니라 `ZokoGames.json`을 가져오세요.
- **조건이 한 번도 true가 되지 않음.** **On request completed**의 태그는 액션에 넘긴 태그와 같아야 하며, 태그당 진행 중인 요청은 하나여야 합니다.
- **액션은 실행되는데 아무 일도 일어나지 않음.** 먼저 **Initialize**를 실행하고 완료를 기다리세요.
- **`sdkNotLoaded`.** 오프라인이거나 SDK 호스트가 차단되었습니다. 미리보기가 스크립트를 불러오려면 인터넷 접속이 필요합니다.
- **광고 요청 뒤의 액션이 늦게 실행됨.** GDevelop이 요청을 기다립니다. 광고는 별도 이벤트에서 시작하세요.
- **배너가 엉뚱한 위치에 있음.** 사각형은 왼쪽 위를 원점으로 하는 게임 해상도 픽셀입니다.

## 다음 단계

- 빌드를 [빌드 검증 규칙](https://docs.zokogames.com/kr/requirements/build-validation)과 [출시 체크리스트](https://docs.zokogames.com/kr/requirements/checklist)에 맞춰 확인하세요.
- 업로드와 게시: [제출 안내](https://docs.zokogames.com/kr/getting-started/submission-walkthrough).
- 다른 엔진과 공통 규칙: [엔진 개요](https://docs.zokogames.com/kr/engines/overview).
