# Godot

`zokogames` 애드온(`packages/sdk-engines/godot/addons/zokogames`)은 **Godot 4** 웹 내보내기를 대상으로 합니다(애드온은 Godot 4.0 이상에서 로드되지만, 포털에서 실행되는 빌드에는 **Godot 4.3 이상**이 필요합니다. 아래 Thread Support를 참고하세요). Godot 3에는 같은 API를 가진 전용 애드온이 있습니다. 아래 [Godot 3](#godot-3)를 참고하세요. 애드온은 오토로드 하나, `ZokoGames`를 등록하며, 이 오토로드는 내보내기 HTML 셸에 정의된 작은 브리지(`window.ZokoBridge`)를 통해 JavaScript SDK와 통신합니다. 브라우저 밖(에디터나 데스크톱 실행)에서는 내장 시뮬레이터가 대신 응답하므로, 같은 코드가 어디서나 실행됩니다. "midgame", "rewarded" 같은 용어는 [용어집](https://docs.zokogames.com/kr/getting-started/glossary)에 있습니다.

> [!NOTE]
> 현재 상태(1.7.0): 공식 Godot 4.3 및 4.7.2 에디터와 실제 브라우저의 웹 내보내기로 실행했습니다(2026-11-23). 애드온은 오류나 경고 없이 가져와지고, 플러그인을 활성화하면 autoload가 등록되며, 모든 공개 메서드와 시그널이 시뮬레이터 모드에서 문서대로 동작하고, 웹 내보내기(4.3, Thread Support 끔)에는 브리지가 포함됩니다. Godot 4.0~4.2는 실행하지 않았습니다. 첫 임포트가 실패하면 Godot 버전과 정확한 오류를 [지원](https://docs.zokogames.com/kr/business/support)으로 보내 주세요.

## 설치 {#install}

Godot 플러그인을 내려받으세요: [/sdk-engines/zokogames-godot-1.7.0.zip](https://www.zokogames.com/sdk-engines/zokogames-godot-1.7.0.zip) (저장소의 폴더와 같은 파일입니다).

[/sdk-engines/godot.zip](https://www.zokogames.com/sdk-engines/godot.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. `addons/zokogames`를 프로젝트의 `res://addons/` 폴더로 복사하세요. 여기에는 `plugin.cfg`, `plugin.gd`, `zokogames.gd`(오토로드), `zoko_banner.gd`, `export/zokogames_shell.html`이 들어 있습니다.
2. **Project > Project Settings > Plugins**에서 **ZokoGames**를 활성화하세요. 그러면 오토로드 `ZokoGames`(`res://addons/zokogames/zokogames.gd`)와 `zokogames/simulator/*` 설정이 등록됩니다.
3. **Project > Export**에서 **Web** 프리셋을 추가하고 **Custom HTML Shell**을 `res://addons/zokogames/export/zokogames_shell.html`로 설정하세요. 이 셸은 엔진보다 먼저 `https://sdk.zokogames.com/zokogames-sdk-v1.js`를 불러오고, `window.ZokoBridge`를 만들며, 엔진 다운로드를 포털의 로딩 바에 보고합니다. 자체 셸을 사용한다면 `<head>`에 스크립트 태그를 추가하고 제공된 셸에서 브리지 블록을 복사하세요.
4. 시작할 때, 다른 어떤 호출보다 먼저 `await ZokoGames.init_async()`를 한 번 호출하세요.
5. 선택 사항: 배너에 내줄 수 있는 공간 위에 `ZokoBanner` 노드(`zoko_banner.gd`)를 추가하세요. 애드온 옆의 `examples/` 폴더에는 `zoko_demo.gd`(키 A, R, G, H, U, F, T, S, B)와 `zoko_store.gd`가 있습니다.

> [!IMPORTANT]
> 커스텀 셸이 없으면 `window.ZokoBridge`가 존재하지 않습니다. 애드온은 경고를 기록하고 시뮬레이터로 대체하므로 게임은 실행되지만 실제 광고, 사용자, 저장 데이터는 사용되지 않습니다.

## Godot 3 {#godot-3}

Godot 3.x(대상은 3.5와 3.6 LTS이며, 3.3과 3.4도 동작할 것입니다)에는 Godot 4 애드온과 같은 공개 API를 가진 전용 애드온이 있습니다. 오토로드 `ZokoGames`, 메서드 이름, 시그널이 모두 같아서 프로젝트를 서로 옮길 수 있습니다. 다운로드: [/sdk-engines/zokogames-godot3-1.7.1.zip](https://www.zokogames.com/sdk-engines/zokogames-godot3-1.7.1.zip). GDScript 1로 작성되었고 `JavaScript` 싱글톤으로 SDK를 호출합니다.

> [!NOTE]
> 현재 상태(1.7.1): 공식 Godot 3.6.3 에디터와 실제 브라우저의 HTML5 웹 내보내기로 실행했습니다(2026-11-23). 애드온은 오류나 경고 없이 가져와지고(경고를 오류로 처리), 플러그인을 활성화하면 autoload가 등록되며, 모든 공개 메서드와 시그널이 시뮬레이터 모드에서 문서대로 동작하고, HTML5 내보내기에는 브리지가 포함됩니다. 버전 1.7.1에서 시뮬레이터가 빈 암호화 점수를 거부하던 문제를 수정했습니다. Godot 3.3~3.5는 검증하지 않았습니다. 첫 임포트가 실패하면 Godot 버전과 정확한 오류를 [지원](https://docs.zokogames.com/kr/business/support)으로 보내 주세요.

설치:

1. 다운로드한 `addons/zokogames`를 프로젝트의 `res://addons/` 폴더에 복사하고 **Project > Project Settings > Plugins**에서 **ZokoGames**를 활성화합니다. 그러면 오토로드 `ZokoGames`가 등록됩니다.
2. **Project > Export**: **HTML5** 프리셋을 추가하고 **Custom HTML Shell**을 `res://addons/zokogames/export/zokogames_shell.html`로 설정합니다. Godot 4 셸과 같은 SDK 스크립트를 불러옵니다. GDNative는 끈 채로 두고, canvas 크기 조절 정책은 **Adaptive**를 사용하세요.
3. `yield(ZokoGames.init_async(), "completed")`로 시작합니다.

Godot 4 애드온과 다른 점:

| Godot 4 | Godot 3 |
| --- | --- |
| `await ZokoGames.get_user_async()` | `yield(ZokoGames.get_user_async(), "completed")`, 같은 Dictionary를 반환합니다 |
| `callback: Callable` | `callback`: `FuncRef`, 즉 `funcref(self, "_on_done")` |
| `ZokoGames.ad_started.connect(f)` | `ZokoGames.connect("ad_started", self, "_on_ad_started")` |
| 애드온이 광고 재생 중에 트리를 일시 정지하고 Master 버스를 음소거하며, 둘 다 되돌리고 포털의 음소거 설정을 Master에 적용합니다(`pause_game_during_ads`, `mute_audio_during_ads`, `follow_portal_mute`, 기본값은 모두 `true`) | 같은 속성과 기본값 |
| `JavaScriptBridge` | `JavaScript` |

Godot 4에서는 Godot 3 애드온이 시작을 거부합니다(`init()`이 `unsupportedEngine`으로 실패합니다). 전체 표와 내보내기 설정은 애드온의 README에 있습니다.

## 어떤 경로를 따를까

| 여러분의 상황 | 할 일 |
| --- | --- |
| 완성된 게임이 있는 Godot 취미 개발자 | 애드온을 복사해 활성화하고, 셸을 설정하고, 아래 스니펫을 추가한 뒤, 스레드를 끄고 내보내서 업로드합니다. |
| 이제 막 시작하는 취미 개발자 | 같은 방식으로 하되, 먼저 에디터에서 모든 호출을 테스트하세요. 시뮬레이터는 브라우저가 필요 없습니다. |

## 동작하는 스크립트 {#a-working-script}

첫 씬의 노드에 붙인 스크립트(또는 자체 오토로드)에 넣으세요. 초기화, 미드게임 광고, 보상형 광고, 게임플레이 시작과 중지, 저장과 불러오기, 리더보드 점수를 모두 다룹니다.

```gdscript
extends Node

func _ready() -> void:
	var res := await ZokoGames.init_async()
	if not res.ok:
		push_warning("ZokoGames unavailable: %s" % res.error.code)
	# The addon pauses the tree and mutes Master during an ad, and follows the portal's mute setting
	# (pause_game_during_ads, mute_audio_during_ads, follow_portal_mute): no ad or mute handlers needed.
	var level := int(ZokoGames.data_get_item("level", "1"))     # load: synchronous Strings
	start_game(level)

# Call when the player takes control, and when play stops.
func on_play_start() -> void:
	if ZokoGames.is_available():
		ZokoGames.gameplay_start()
func on_play_stop() -> void:
	if ZokoGames.is_available():
		ZokoGames.gameplay_stop()

func show_midgame() -> void:
	var res := await ZokoGames.request_ad_async("midgame")     # completes after the ad is over
	if not res.ok:
		print("no ad: ", res.error.code)                       # adCooldown, unfilled, adblock ...

func on_reward_button() -> void:
	var res := await ZokoGames.request_ad_async("rewarded")
	if res.ok:
		grant_reward()                                         # reward only after the ad finished

func save_progress(level: int) -> void:
	var r := ZokoGames.data_set_item("level", str(level))      # synchronous, uploaded in the background
	if not r.ok:
		push_warning(r.error.code)                             # for example dataLimitExceeded

func submit_score(score: float) -> void:
	var user := await ZokoGames.get_user_async()
	if not user.ok or user.result == null:
		return                                                 # guests are not ranked
	var r := await ZokoGames.submit_score_async("", score)     # "" works only on a board WITHOUT an encryption key
	if not r.ok:
		print(r.error.code)

func start_game(_level: int) -> void: pass
func grant_reward() -> void: pass
```

애드온은 `ad_started`부터 `ad_finished` 또는 `ad_error`까지 트리를 일시 정지하고, 그동안 Master 버스를 음소거하며, 초기화 후와 변경될 때마다 포털의 음소거 설정을 Master에 적용합니다(`ZokoGames` 오토로드의 `pause_game_during_ads`, `mute_audio_during_ads`, `follow_portal_mute`, 모두 `true`. 그 부분을 직접 처리하려면 하나를 `false`로 설정하세요). 오토로드는 `PROCESS_MODE_ALWAYS`로 실행되므로 트리가 일시 정지되어도 시그널이 도착합니다. 광고 중에 반응해야 하는 여러분의 노드에는 처리 모드 **Always**가 필요합니다.

리더보드에 대한 설명입니다. 암호화 키가 **있는** 보드는 올바르게 암호화된 페이로드만 인정하며([리더보드](https://docs.zokogames.com/kr/sdk/leaderboards#client-submission)), 어떤 엔진 래퍼도 암호화 도우미를 제공하지 않으므로 `""`는 키가 없는 보드에서만 동작합니다. 키가 있는 보드에서는 직접 암호화하거나(AES-256-GCM, 추가 데이터 `zoko-score-v1|<userId>|<gameId>`이며, 플레이어 ID는 `get_user_async`가 반환하는 `user.result.__dangerousUserId`입니다) 점수를 서버에서 계산해 서버 API를 사용하세요.

## 호출 방식 {#how-calls-work}

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

GDScript의 이름은 snake_case입니다. 포털과 통신하는 모든 메서드는 두 가지 형태로 제공됩니다.

| 형태 | 예 | 용도 |
| --- | --- | --- |
| 콜백 | `ZokoGames.get_user(callback)` | 결과를 기다리지 않는(fire-and-forget) 호출. `Callable`은 선택 사항이며 마지막에 오지만, `store_get_catalog_items(callback, limit, offset)`와 `store_get_player_inventory(callback, limit, offset)`에서는 맨 앞에 오고, `get_user_token(signing_key_type, callback)`에서는 두 번째에 옵니다. |
| Awaitable | `await ZokoGames.get_user_async()` | 위에서 아래로 읽히는 코드. 이름이 `_async`로 끝납니다. |

두 형태 모두 Dictionary를 전달합니다. `{ "ok": true, "result": <value> }` 또는 `{ "ok": false, "error": { "code": "...", "message": "..." } }`입니다(`request_ad`는 대신 callable의 Dictionary를 받습니다). 모든 메서드는 오토로드에 직접 있으며 `ad.`, `game.`, `user.` 같은 하위 객체는 없습니다.

| JavaScript | GDScript |
| --- | --- |
| `SDK.init()` | `await ZokoGames.init_async()` 또는 `ZokoGames.init(callback)`. 시그널 `initialized(ok)` |
| `SDK.environment` | `ZokoGames.environment`(`"local"`, `"zokogames"`, `"disabled"`), `ZokoGames.is_available()`, `ZokoGames.is_simulated`, `ZokoGames.is_qa_tool`, `ZokoGames.VERSION` |
| `SDK.ad.requestAd(type, cbs)` | `ZokoGames.request_ad(type, {"ad_started": f, "ad_finished": f, "ad_error": f})` 또는 `await ZokoGames.request_ad_async(type)` |
| `SDK.ad.hasAdblock()` | `ZokoGames.has_adblock(callback)` 또는 `await ZokoGames.has_adblock_async()` |
| `SDK.banner.requestBanner(...)` | `await ZokoGames.request_banner_async(id, width, height, window_rect)` |
| `SDK.banner.requestResponsiveBanner(id)` | `await ZokoGames.request_responsive_banner_async(id, window_rect)` |
| `SDK.banner.clearBanner(id)` / `clearAllBanners()` | `ZokoGames.clear_banner(id)` / `ZokoGames.clear_all_banners()` |
| `SDK.game.gameplayStart()` / `gameplayStop()` | `ZokoGames.gameplay_start()` / `ZokoGames.gameplay_stop()` |
| `SDK.game.loadingStart()` / `loadingStop()` / `loadingProgress(n)` | `ZokoGames.loading_start()` / `loading_stop()` / `loading_progress(n)` |
| `SDK.game.happytime()` | `ZokoGames.happytime()` |
| `SDK.game.reportGameCompletedPercentage(n)` | `ZokoGames.report_game_completed_percentage(n)` |
| `SDK.game.setGameContext(obj)` / `clearGameContext()` | `ZokoGames.set_game_context(dict)` / `ZokoGames.clear_game_context()` |
| `SDK.game.updateRoom(u)` / `leftRoom()` | `ZokoGames.update_room(dict)` / `ZokoGames.left_room()` |
| `SDK.game.inviteLink(p)` / `getInviteParam(k)` | `await ZokoGames.invite_link_async(dict)` / `ZokoGames.get_invite_param(key)` |
| `SDK.game.showInviteButton(p)` / `hideInviteButton()` | `await ZokoGames.show_invite_button_async(dict)` / `ZokoGames.hide_invite_button()` |
| `SDK.game.settings` | `ZokoGames.settings`(`disableChat`, `muteAudio`), 시그널 `settings_changed` |
| `SDK.game.isOffline`, 오프라인 리스너 | `ZokoGames.is_offline`, 시그널 `offline_changed(offline)` |
| `SDK.game.isInstantMultiplayer` / `inviteParams` | `ZokoGames.is_instant_multiplayer`(별칭 `is_instant_join`) / `ZokoGames.invite_params`, 시그널 `join_room(params)` |
| `SDK.user.isUserAccountAvailable` / `systemInfo` | `ZokoGames.is_user_account_available` / `ZokoGames.system_info` |
| `SDK.user.getUser()` | `await ZokoGames.get_user_async()` |
| `SDK.user.getUserToken(opts)` | `await ZokoGames.get_user_token_async(signing_key_type)` |
| `SDK.user.showAuthPrompt()` | `await ZokoGames.show_auth_prompt_async()`, 시그널 `auth_changed(user)` |
| `SDK.user.showAccountLinkPrompt()` | `await ZokoGames.show_account_link_prompt_async()` |
| `SDK.user.listFriends(opts)` | `await ZokoGames.list_friends_async(page, size)` |
| `SDK.user.submitScore(opts)` | `await ZokoGames.submit_score_async(encrypted_score, score)` |
| `SDK.data.getItem(k)` / `setItem(k, v)` | `ZokoGames.data_get_item(key, default)` / `ZokoGames.data_set_item(key, value)`. `data_has_key`, `data_remove_item`, `data_clear`도 있음(모두 동기) |
| `SDK.store.*` | `store_get_catalog_items_async`, `store_get_player_inventory_async`, `store_buy_item_async(item_id)`, `store_consume_item_async(sku, qty)`, `store_get_purchase_token_async()`, `is_store_available`, `store_set_sandbox(bool)`(동기). 시그널 `purchase_completed(item_id)`, `purchase_failed(error)` |
| `SDK.achievements.list()` / `unlock(key)` / `onUnlock` | `await ZokoGames.achievements_list_async()` / `achievements_unlock_async(key)`, 시그널 `achievement_unlocked(achievement)`. [업적](https://docs.zokogames.com/kr/sdk/achievements) 참고 |
| `SDK.analytics.trackOrder(p, o)` | `await ZokoGames.track_order_async(provider, order)` |
| `SDK.analytics.track(name, params)` (1.7.0) | `ZokoGames.track(name, params)` / `track_async(name, params)` |

오토로드의 시그널: `initialized`, `ad_started`, `ad_finished`, `ad_error(error)`, `auth_changed`, `settings_changed`, `offline_changed`, `join_room`, `purchase_completed`, `purchase_failed`. 오류 코드는 `ZokoGames.ERROR_CODES`(모듈을 키로 하는 Dictionary이며, 예를 들어 `ZokoGames.ERROR_CODES.ad`)에 있고, `ZokoGames.has_error_code(res, "purchaseCancelled")`로 결과를 검사할 수 있습니다.

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

## 방 데이터 채널

SDK 1.3.0에서 추가되었습니다. 방 데이터 채널을 사용하면 한 방의 플레이어끼리 작은 JSON 메시지를 주고받고 호스트만 쓸 수 있는 아주 작은 상태를 공유할 수 있어서, 간단한 멀티플레이어 게임에는 자체 서버가 필요 없습니다. 이것은 게임 데이터용이며 텍스트 채팅용이 아닙니다. `updateRoom` 이후(또는 초대로 참여한 이후)부터 `leftRoom`까지 존재하고, 로그인한 플레이어와 실시간 기능이 켜진 포털이 필요하며(그렇지 않으면 `roomUnavailable`), 한도는 메시지 또는 patch당 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으로 브리지를 건너갑니다. Dictionary, Array, String, 숫자, bool, null을 사용하세요(숫자는 `float`로 돌아옵니다). 브라우저 밖에서는 시뮬레이터가 멤버 한 명이 있는 방 하나이며 자기 자신의 메시지와 상태 변경을 받습니다.

| JavaScript | Godot |
| --- | --- |
| `room.send(data, { to })` | `ZokoGames.room_send(data, to, cb)` / `room_send_async(data, to)` / `room_send_to(member_id, data, cb)` |
| `room.onMessage(cb)` | 시그널 `room_message(message)`(`from`, `data`, `direct`, `seq`, `ts`) |
| `room.setState(patch)` | `room_set_state(patch, cb)` / `room_set_state_async(patch)`(`null` 값은 키를 제거) |
| `room.getState()`, `room.onState(cb)` | `room_get_state()`, `room_get_state_value(key, default)`. 시그널 `room_state(state, change)` |
| `room.members()`, `room.onMembers(cb)` | `room_get_members()`. 시그널 `room_members(members)` |
| `room.isHost()`, `room.onHostChange(cb)`, `room.selfId` | `room_is_host()`. 시그널 `room_host_changed(host_id, is_host)`. `room_self_id()` |
| `room.addLeftListener(cb)` (1.7.0) | 시그널 `room_left(reason, room_id)` |
| `room.onError(cb)` | 시그널 `room_error(error)` |

```gdscript
func _ready() -> void:
	await ZokoGames.init_async()
	ZokoGames.room_message.connect(func(m: Dictionary) -> void: print(m.from, " played ", m.data))
	ZokoGames.room_host_changed.connect(_on_host_changed)
	await ZokoGames.update_room_async({"roomId": "match-1", "isJoinable": true})

func _on_host_changed(_host_id: String, is_host: bool) -> void:
	if is_host:
		ZokoGames.room_set_state({"turn": "X"})

func play_cell(cell: int) -> void:
	await ZokoGames.room_send_async({"cell": cell, "mark": "X"})
```

## 배너

배너 사각형은 창 픽셀 단위입니다. 배너가 들어갈 위치에 `ZokoBanner` 노드(`Control`)를 놓으세요. 이 노드는 화면상의 사각형 영역(스트레치 모드를 반영)을 보고하고, `_ready`에서 요청하며, 트리에서 빠질 때 스스로 지웁니다.

| 속성 | 의미 |
| --- | --- |
| `container_id` | 배너 ID, 기본값 `zoko-banner`. |
| `size_mode` | `responsive`(들어맞는 가장 큰 크기) 또는 `728x90`, `300x250`, `320x50`, `468x60`, `320x100` 중 하나. |
| `request_on_ready` | `_ready`에서 자동으로 요청합니다. |
| `show_simulator_placeholder` | 시뮬레이터가 응답하는 동안 자리 표시용 사각형을 그립니다. |

직접 요청하려면 `await ZokoGames.request_responsive_banner_async("menu", $BannerSlot.get_global_rect())`를 사용하세요. 배너는 메뉴 화면에서만 요청하세요.

## 구매

```gdscript
func buy_first_item() -> void:
	if not ZokoGames.is_store_available:
		return
	var catalog := await ZokoGames.store_get_catalog_items_async()
	if not catalog.ok or catalog.result.is_empty():
		return
	var bought := await ZokoGames.store_buy_item_async(catalog.result[0].sku)
	if ZokoGames.has_error_code(bought, "purchaseCancelled"):
		return
	var token := await ZokoGames.store_get_purchase_token_async()   # send to your server and verify there
```

소유권은 서버에서 검증하세요([게임 내 구매](https://docs.zokogames.com/kr/sdk/purchases) 참고). `examples/zoko_store.gd`가 전체 흐름입니다.

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

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

- **Custom HTML Shell**: 위에서 설명한 대로 `res://addons/zokogames/export/zokogames_shell.html`. 캔버스 크기 조정은 셸이 처리하므로(캔버스가 프레임을 가득 채우며 `width`와 `height`가 100퍼센트), Project Settings > Display > Window > Stretch에서 **Stretch Mode**는 `canvas_items`, aspect는 `expand` 또는 `keep`으로 설정하세요.
- **Thread Support: 끄기.** 스레드를 쓰는 내보내기에는 `SharedArrayBuffer`가 필요하고, 이는 교차 출처 격리(COOP와 COEP 헤더)가 필요합니다. 게임 페이지는 이 헤더 없이 서빙되므로 스레드 빌드는 시작할 수 없습니다(증상: `SharedArrayBuffer is not defined` 또는 빈 캔버스). 싱글 스레드 웹 내보내기를 사용하세요. Godot 4.3 이상에서는 Web 프리셋에서 **Thread Support**를 체크 해제하세요. Godot 4.0~4.2에는 이 옵션이 없어(웹 내보내기가 항상 `SharedArrayBuffer`를 사용합니다) 포털에서 실행할 수 없으므로, 4.3 이상에서 내보내세요. Extensions Support는 필요하지 않다면 끄세요.
- **파일 이름.** 내보내기 경로에 `index.html`이라는 이름을 입력해 그 이름의 파일로 내보내세요. 포털은 아카이브 루트에 `index.html`이 있어야 하며, 내보내기는 나머지 파일의 이름을 이것에 맞춰 짓습니다. `index.js`, `index.wasm`, `index.pck`와 오디오 워크릿 스크립트입니다. 이름을 `.br`이나 `.gz`로 바꾸지 **마세요**. 엔진은 일반 이름으로 요청합니다. 게임 오리진은 `.br` 또는 `.gz`로 끝나는 파일에 맞는 `Content-Encoding` 헤더를 붙이지만 이는 접미사 기준이어서, 정확히 그 이름을 요청하는 엔진(Unity는 그렇고 Godot는 그렇지 않음)에만 도움이 됩니다. 포털은 일반 파일의 전송 압축을 문서화하지 않으며 초기 다운로드 추정은 압축 전 크기를 사용하므로, `.wasm`과 `.pck`를 작게 유지하세요.
- **텍스처 압축.** 내보내기 프리셋에서 데스크톱(S3TC/BPTC)과 모바일(ETC2/ASTC) 모두에 VRAM 압축을 활성화해, 모든 브라우저에서 사용할 수 있는 형식이 있게 하세요.
- **크기.** 사용하지 않는 모듈을 끈 커스텀 내보내기 템플릿을 사용하고 `.pck`를 작게 유지하세요. 한도: 파일 1,500개, 압축 해제 기준 250 MB, 초기 다운로드 약 50 MB(모바일은 20 MB). Export With Debug: 끄기.
- **메모리.** 모바일 브라우저는 힙이 작습니다. 모든 레벨의 텍스처를 처음에 한꺼번에 불러오지 말고, 첫 씬 이후 `ResourceLoader.load_threaded_request`로 스트리밍하세요(스레드 풀 로딩은 비스레드 내보내기에서도 동작합니다). 휴대폰에서는 해상도를 제한하세요. [모바일](https://docs.zokogames.com/kr/guides/mobile)을 참고하세요.
- **오디오 잠금 해제.** 브라우저는 첫 클릭이나 키 입력이 있을 때까지 오디오를 일시 중단 상태로 둡니다. Godot는 첫 입력 이후에 오디오를 시작하므로, "클릭하여 플레이" 화면을 표시하고 `_ready`가 아니라 그 입력에서 음악을 시작하세요.
- **전체 화면.** 프레임 전체를 전체 화면으로 만드는 포털 프레임 바의 전체 화면 버튼을 사용하세요. 프레임은 전체 화면이 허용되므로 `DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)`도 동작하지만 이는 캔버스만 전체 화면으로 만드니, 경쟁하는 버튼을 추가하지 마세요.
- **로딩.** 셸이 이미 엔진 다운로드를 보고하고 엔진이 시작되면 `loadingStop`을 호출합니다. 게임 내에서 더 긴 로딩 화면을 쓰려면 `ZokoGames.loading_start()`, `loading_progress(percent)`, `loading_stop()`을 직접 호출하세요.

업로드: **Project > Export > Web > Export Project**를 실행하고, 폴더의 내용물을 압축해 `index.html`이 아카이브 루트에 오게 한 뒤 개발자 콘솔에서 업로드하세요. 먼저 [미리보기 도구](https://www.zokogames.com/kr/preview)를 실행하세요.

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

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

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

- **에디터나 데스크톱 실행에서는** `ZokoGames.is_simulated`가 true입니다. 시뮬레이터는 **Project Settings > zokogames/simulator**에서 조정하세요. `ad_behaviour`(`fill`, `no_fill`, `error`), `ad_duration_seconds`(기본 1.5), `adblock`, `disabled`, `account_available`, `logged_in`, `username`, `user_id`, `friend_count`, `mute_audio`, `disable_chat`, `offline`, `store_available`, `verbose`가 있습니다. 클라우드 저장은 `user://zoko_sim_data.json`에, 시뮬레이션된 인벤토리는 `user://zoko_sim_inventory.json`에 있습니다.
- **기억해 둘 차이점.** 시뮬레이터는 포털과 브라우저의 로컬 모드가 적용하는 3분 미드게임 쿨다운(`adCooldown`)을 적용하지 않습니다.
- **`localhost`의 웹 내보내기.** 내보내기 폴더를 `localhost`의 로컬 웹 서버로 서빙하세요(디스크에서 `index.html`을 여는 방식은 WebAssembly에서 동작하지 않습니다). 브리지가 존재하므로 `is_simulated`는 false이고, JavaScript SDK가 자체 [로컬 모드](https://docs.zokogames.com/kr/getting-started/local-testing)로 실행됩니다. 3초짜리 광고 오버레이, 가짜 플레이어, `localStorage` 저장, `?sdk_debug=true`, `?ad_response=unfilled`가 적용됩니다.
- **그다음** 로컬 주소로 [미리보기 도구](https://www.zokogames.com/kr/preview)를 열고 체크리스트가 채워지는 것을 확인하세요.

## 알려진 함정

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

- **`sdkNotLoaded`.** 페이지에 SDK 스크립트 태그가 없습니다. 커스텀 셸을 사용하세요.
- **`ZokoGames` 오토로드가 없습니다.** 플러그인이 활성화되지 않았습니다.
- **호출이 `sdkNotInitialized`로 실패합니다.** 먼저 `await ZokoGames.init_async()`를 호출하세요.
- **에디터에서는 되는데 브라우저에서는 안 됩니다.** 브라우저 콘솔을 열고 `window.ZokoBridge`가 존재하는지 확인하세요(셸이 정의합니다).
- **광고가 끝난 뒤에도 게임이 일시정지 상태입니다.** `ad_finished`뿐 아니라 `ad_error`에서도 재개하세요. `ad_started`에 `CONNECT_ONE_SHOT`을 사용하지 마세요. 광고가 실패하면(`unfilled`, `adCooldown`, `adblock`) `ad_started`는 발생하지 않아서 일회성 연결이 다음 광고를 위해 그대로 남습니다.
- **배너가 전혀 표시되지 않습니다.** `ZokoBanner` 노드에는 크기가 필요하며 보이는 상태여야 합니다.
- **스레드 내보내기가 시작되지 않습니다.** Thread Support를 끄세요.

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

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

SDK 1.4.0부터: `ZokoGames.report_chat({"reportedName": "Trixie", "message": "buy gold", "reason": "spam"}, callback)`(또는 `report_chat_async`), `ZokoGames.set_screenshot_provider(callable)`(`frame_post_draw` 이후의 뷰포트 캡처가 기본으로 등록됨), 그리고 `mirror_error` 시그널과 함께 쓰는 `ZokoGames.mirror_local_storage({"prefix": "save_"})`가 있습니다. Godot 자체의 `user://` 파일은 `localStorage`가 아니라 IndexedDB에 있으므로 미러가 보지 못합니다. 이 파일은 `data_set_item`으로 저장하세요. 에디터 시뮬레이터는 세 가지를 모두 받아들입니다. Godot 3의 애드온에도 같은 함수가 있습니다.

## 다음 단계

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