# Construct 3

**ZokoGames** 애드온(`zokogames.c3addon`, 플러그인 id `zokogames`, SDK v2, 단일 전역 객체)은 `packages/sdk-engines/construct3`에 있습니다. 모든 SDK 작업은 DOM 쪽 스크립트(`c3runtime/domside.js`)에서 페이지의 메인 스레드로 실행되므로 Construct의 워커 모드에서도 동작하며, 런타임은 이 스크립트와 일반 결과를 주고받습니다. "midgame", "rewarded" 같은 용어는 [용어집](https://docs.zokogames.com/kr/getting-started/glossary)에 있습니다.

> [!NOTE]
> 현재 상태(1.7.2): 애드온을 Construct 3 r506.4 에디터에 설치했고, 에디터로 만든 내보내기는 프로덕션 검사를 통과합니다(12개 영역, 1.7.1 기준). 워커 없는 모드, 두 플레이어의 방, 상점 오류, 설정·음소거·오프라인 이벤트, 요청 차단, Initialize 이전의 동작을 다루는 내보내기 7개를 2026-11-23에 로컬에서 실행했습니다. 버전 1.7.2는 Update room 이후의 방 값을 수정합니다. 애드온이 로드되지 않으면 Construct 버전과 정확한 오류를 [지원](https://docs.zokogames.com/kr/business/support)으로 보내 주세요.

## 설치 {#install}

Construct 3 플러그인을 내려받으세요: [/sdk-engines/zokogames-construct3-1.7.2.zip](https://www.zokogames.com/sdk-engines/zokogames-construct3-1.7.2.zip). 설치 가능한 `zokogames.c3addon`(저장소의 `construct3` 폴더에서 빌드됨), README, 변경 기록이 들어 있습니다.

[/sdk-engines/construct3.zip](https://www.zokogames.com/sdk-engines/construct3.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. 내려받은 파일의 압축을 풀고 **Menu > View > Addon Manager > Install new addon**에서 **`zokogames.c3addon`**(zip이 아닙니다)을 설치하세요. 저장소에서 직접 빌드한다면 `pnpm --filter @zoko/sdk-engines package`가 같은 파일이 든 `zokogames-construct3-<version>.zip`을 만듭니다([개요](https://docs.zokogames.com/kr/engines/overview#getting-the-plugin) 참고).
2. Construct 3를 다시 시작한 뒤 **Insert new object > ZokoGames**를 실행하세요. 단일 전역 객체이므로 하나면 충분합니다. 이 애드온은 Addon SDK v2를 사용하며 Construct 3 r397 이상이 필요합니다.
3. 첫 레이아웃이 시작될 때 **Initialize** 액션을 실행하세요. 페이지에 SDK가 없으면 DOM 쪽 스크립트가 `https://sdk.zokogames.com/zokogames-sdk-v1.js`를 직접 불러오므로 내보내기 파일을 수정할 필요가 없습니다.
4. HTML5 웹사이트로 내보내 zip을 업로드하세요.

## 어떤 경로를 따를까

| 해당하는 경우 | 할 일 |
| --- | --- |
| 완성된 게임이 있는 Construct 취미 개발자 | 애드온을 설치하고 **Initialize**와 아래 광고 이벤트를 추가한 뒤 HTML5 웹사이트로 내보내 업로드하세요. 스크립트는 필요 없습니다. |
| 스크립트에 익숙한 경우 | 워커 모드가 꺼져 있으면 같은 SDK를 스크립트에서 사용할 수 있습니다([스크립트](#scripting) 참고). |

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

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

모든 비동기 액션은 **Tag**를 받습니다. 호출이 끝나면 그 태그의 **On request completed** 또는 **On request failed**가 발생하고, **On any request failed**는 모든 실패에서 발생합니다. 진행 중인 요청마다 태그를 하나씩 사용하세요. 모든 액션은 비동기이므로, 액션 뒤에 **System: Wait for previous actions to complete**를 두면 호출이 끝날 때까지 기다립니다.

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

## 동작하는 이벤트 시트 {#a-working-event-sheet}

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

```
System: On start of layout (first layout)
    -> ZokoGames: Initialize (tag "init")

ZokoGames: On request completed ("init")
    -> ZokoGames: Get saved item (tag "load", key "best")           // load; saves are asynchronous in worker mode
ZokoGames: On request completed ("load")
    + ZokoGames: has saved item "best"  (compare HasSavedItem("best") = 1)
    -> Set Best to int(SavedItem("best"))
ZokoGames: On request failed ("init")                               // SDK missing or blocked: just start
    -> Go to layout "Menu"
ZokoGames: On request completed ("load")  or  On request failed ("load")
    -> Go to layout "Menu"                                          // a failed load (data module off) must not block the game

// Ads: pause on start, resume on finish AND error. Never pause in the action itself.
ZokoGames: On ad started
    -> System: Set time scale 0 ; Audio: Set silent
ZokoGames: On ad finished
    -> System: Set time scale 1 ; Audio: Set not silent
    + System: Compare variable RewardPending = 1
    -> Add 10 to Coins ; Set RewardPending to 0
ZokoGames: On ad error
    -> System: Set time scale 1 ; Audio: Set not silent ; Set RewardPending to 0

// Loading: the portal's loading bar ends here (once, when the menu can be used)
Menu layout: On start of layout
    + ZokoGames: Is available
    -> ZokoGames: Loading stop (tag "ls")

// Gameplay start/stop
Game layout: On start of layout (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 (e.g. on the game-over screen)
Game over screen: On start of layout
    + ZokoGames: Is available
    -> ZokoGames: Request ad (type midgame, tag "mid")

// Rewarded ad
Reward button: On 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 str(Best))

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

// Mute setting
ZokoGames: On settings changed
    + ZokoGames: Is mute requested
    -> Audio: Set silent
ZokoGames: On settings changed
    + Else
    -> Audio: Set not silent
```

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

- **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
    -> Shop button: Set visible ; ZokoGames: Get catalogue items (limit 50, offset 0, tag "cat")
ZokoGames: On request completed ("cat")
    -> loop 0..StoreItemCount-1: row with StoreItemName(loopindex), StoreItemPrice(loopindex), StoreItemCurrency(loopindex)
Buy button: On clicked
    -> ZokoGames: Buy item (StoreItemSku(selected), tag "buy")
ZokoGames: On request completed ("buy")
    -> grant 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** |
| 배너 | **Request banner**(id, 크기 728x90, 300x250, 320x50, 468x60 또는 320x100, x, y, w, h), **Request responsive banner**(id, x, y, w, h), **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** |
| 멀티플레이어 | **Update room**, **Set room public**, **Left room**, **Create invite link**, **Show invite button**과 **Hide invite button**(더 이상 권장되지 않음) |
| 사용자 | **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** |
| 업적 | **Unlock achievement**(키), **List achievements** |
| 분석 | **Track order**, **Track event** (이름, JSON 매개변수; SDK 1.7.0) |

배너 사각형은 왼쪽 위를 원점으로 하는 캔버스 CSS 픽셀 단위이며, 애드온이 이를 캔버스의 비율로 변환합니다. 배너는 메뉴 레이아웃에서만 요청하세요.

## 조건

<!-- 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**.
- 오프라인: **On offline changed**, **Is offline**, 그리고 표현식 `IsOffline`(1 또는 0). 1.6.1 이전에는 이 표현식이 이벤트 시트에서 실패했습니다. 사용 중이라면 애드온을 업데이트하세요.
- 멀티플레이어: **Is instant multiplayer**, **On join room**.
- 업적: **On achievement unlocked**.
- 계정: **On auth changed**, **Is logged in**, **Is account available**.
- 스토어: **Is store available**.

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

## 표현식

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

`Environment`, `SdkVersion`, `MuteAudio`, `DisableChat`, `IsOffline`, `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`의 쉼표로 구분한 코드), `ResultJSON`, `ResultString`, `ResultNumber`, `ErrorCode`, `ErrorMessage`, `ErrorContainerId`, 스토어 표현식 `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` 중 하나입니다. 업적이 잠겨 있는 동안 `AchievementUnlockedAt(i)`는 비어 있습니다. [업적](https://docs.zokogames.com/kr/sdk/achievements)을 참고하세요.

## 스크립트 {#scripting}

SDK는 스크립트에서 호출할 수 있지만, Project Properties에서 **Use worker**가 꺼져 있을 때만 가능합니다. 워커를 쓰면 런타임에 `window`가 없어 스크립트에서 `globalThis.ZokoGames`가 존재하지 않습니다. 스크립트는 **Initialize**가 완료된 뒤에만 실행하세요.

```js
// Script event, after the "init" request completed. Needs Use worker = No.
const SDK = globalThis.ZokoGames.SDK;
const user = await SDK.user.getUser();
runtime.globalVars.PlayerName = user ? user.username : "guest";
```

## 방 데이터 채널

SDK 1.3.0에서 추가되었습니다. 방 데이터 채널을 사용하면 한 방의 플레이어끼리 작은 JSON 메시지를 주고받고, 호스트만 쓸 수 있는 작은 상태를 공유할 수 있어서 간단한 멀티플레이어 게임에 자체 서버가 필요 없습니다. 텍스트 채팅이 아니라 게임 데이터를 위한 것입니다. 채널은 `updateRoom` 이후(또는 초대를 통해 참여한 뒤)에 생기고 `leftRoom`으로 끝나며, 로그인한 플레이어와 실시간 기능이 켜진 포털이 필요합니다(그렇지 않으면 `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)에 있습니다.

**Room** 카테고리가 이를 제공합니다. 메시지와 값 파라미터는 텍스트나 숫자를 받습니다. 올바른 JSON(`{"x":1}`, `5`, `true`)은 그 JSON 값으로 전송되고, 그 외에는 일반 텍스트로 전송됩니다. 방 상태, 멤버 목록, 호스트, 자신의 id는 방 이벤트에서 캐시되므로 표현식은 워커 모드에서도 동작합니다. `localhost`에서는 SDK의 로컬 모드가 같은 방 id에 참여한 두 브라우저 탭을 두 명의 플레이어처럼 동작하게 합니다.

| 종류 | ACE |
| --- | --- |
| 액션 | **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; 표현식 `RoomLeftReason`, `RoomLeftRoomId`), **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` |
| 오류 표현식 | `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")
Board: On cell clicked             -> ZokoGames: Send room message ("{""cell"":" & Cell & "}", tag "move")
ZokoGames: On room message         -> Board: Place cell ZokoGames.RoomMessageValue("cell")
ZokoGames: On room state changed   -> Text: Set text to ZokoGames.RoomStateValue("turn")
```

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

- **HTML5 웹사이트로 내보내기**를 선택하고, `index.html`이 압축 파일의 루트에 오도록 내보내기 폴더의 **내용물**을 zip으로 묶으세요.
- **Offline support: No**(서비스 워커를 추가하며, 포털 자체의 오프라인 처리와 충돌할 수 있어 검증기가 `service_worker` 경고를 냅니다). **Use worker: Yes**는 지원됩니다. **Minify script: Simple 또는 Advanced**.
- **사전 압축 금지.** Construct는 `.br`이나 `.gz`를 만들지 않으므로 내보낸 결과를 그대로 업로드하세요. 게임 오리진은 `.br` 또는 `.gz` 접미사를 해당 `Content-Encoding`과 함께 제공하지만 Construct는 일반 이름으로 요청하므로, 이름을 바꾼 파일은 동작하지 않습니다. 최초 다운로드 추정치는 압축하지 않은 크기를 기준으로 하니, 이미지(WebP)와 오디오(Opus 또는 AAC)를 압축하고 용량이 큰 미디어는 첫 레이아웃이 상호작용 가능해진 뒤 불러오는 두 번째 레이아웃에 두세요. 한도: 파일 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 > Fullscreen mode)을 letterbox 또는 scale-outer 모드로 설정하세요.
- **오디오 잠금 해제.** 브라우저는 첫 클릭이나 탭 전까지 오디오를 일시 중단 상태로 둡니다. 음악은 레이아웃 시작 시가 아니라 첫 레이아웃의 "탭하여 시작" 버튼에서 재생하세요.
- **전체 화면.** 포털 프레임 바의 전체 화면 버튼(프레임 전체를 전체 화면으로 만듭니다)을 사용하는 것이 좋습니다. 프레임이 전체 화면을 허용하므로 Construct의 **Request fullscreen**도 입력 이벤트에서는 동작하지만, 캔버스만 전체 화면이 되니 경쟁하는 버튼은 추가하지 마세요.
- **메모리.** 큰 프로젝트는 모든 레이아웃의 데이터를 미리 불러옵니다. 잘 쓰이지 않는 레이아웃은 분리하고, 특히 모바일에서는 스프라이트 시트를 작게 유지하세요.
- **로딩.** 로더 레이아웃에서 **Loading start**를 한 번 실행하고, 매 틱마다 **Report loading progress**(`loadingprogress * 100`)를 실행하며, 첫 게임 레이아웃이 시작되면 **Loading stop**을 실행하세요.

광고, 로그인이나 계정 연결 창, 구매가 끝나면 키보드 포커스가 저절로 게임 프레임과 canvas로 돌아오므로, 클릭하지 않아도 플레이어의 키가 다시 작동합니다.

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

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**가 있습니다. 기본적으로 런타임 캔버스가 포털의 스크린샷 요청에 응답합니다. Local storage 오브젝트는 데이터를 IndexedDB에 보관하므로 미러가 복사하지 않습니다. 그런 저장에는 Data 액션을 사용하세요. 에디터 미리보기는 시뮬레이터를 사용합니다.

## 광고 규칙 {#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입니다.

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

## 알려진 함정

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

- **애드온이 설치되지 않음.** zip이 아니라 `zokogames.c3addon`을 설치하세요.
- **조건이 발생하지 않음.** **On request completed**의 태그는 액션에 넘긴 태그와 같아야 하며, 태그당 진행 중인 요청은 하나여야 합니다.
- **액션은 실행되는데 아무 일도 일어나지 않음.** 먼저 **Initialize**를 실행하고 완료를 기다리세요.
- **`sdkNotLoaded`.** 오프라인이거나 SDK 호스트가 차단되었습니다. 미리보기가 스크립트를 불러오려면 인터넷 접속이 필요합니다.
- **게임이 일시 중지되거나 무음으로 남음.** **On ad finished**뿐 아니라 **On ad error**에서도 재개하세요.
- **배너가 엉뚱한 위치에 있음.** 사각형은 왼쪽 위를 원점으로 하는 캔버스 CSS 픽셀입니다.
- **불러온 직후 저장 항목이 비어 있음.** 읽기는 비동기입니다. `SavedItem`을 읽기 전에 해당 태그의 **On request completed**를 기다리세요.

## 다음 단계

- 빌드를 [빌드 검증 규칙](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).
