Skip to content

플랫폼 (웹·삼성) ​

HTML5 SDK는 플랫폼 어댑터 구조예요. 공통 API(로그인·저장·랭킹·결제·광고)는 같고, 플랫폼마다 다른 부분을 어댑터가 맞춰 줘요.

어댑터플랫폼로그인결제광고
WKWebPlatform일반 웹사이트게스트, Google·Apple—직접 연결 (선택)
WKSamsungPlatform삼성 Instant Plays삼성 계정 / 게스트삼성 IAPSamsung Ads + AdMob

지원 플랫폼은 계속 늘어나요.

웹 ​

js
const api = await WKGameApi.init({
  appKey: '…',
  platform: new WKGameApi.WKWebPlatform({
    // 포털 광고 SDK 를 쓰면 연결 (선택)
    showAd: (format) => portal.showAd(format).then((ok) => ({ shown: true, rewarded: ok })),
  }),
})

삼성 Instant Plays ​

js
const api = await WKGameApi.init({
  appKey: '…',
  platform: new WKGameApi.WKSamsungPlatform({
    ads: {                                    // 광고를 쓰지 않으면 생략
      gameTitle: 'My Game',                   // 영문
      samsungRewardedAdPlacementId: '…',
      samsungInterstitialAdPlacementId: '…',
      admobRewardedAdUnitId: '…',
      admobInterstitialAdUnitId: '…',
    },
  }),
})
api.platform.onAccountChange(() => api.platform.restart())   // 삼성 규격: 계정이 바뀌면 재시작
api.platform.onPause(() => pauseGame())
api.platform.onResume(() => resumeGame())
멤버설명
setLoadingProgress(n)삼성 로딩 화면 진행률
start()startGameAsync — 로딩 화면 제거
platform.loginStatus()LOGIN / NO_LOGIN / IN_PROGRESS
platform.restart()게임 재시작

삼성 시작 템플릿 ​

html
<!doctype html>
<html lang="ko">
<head>
  <meta charset="utf-8">
  <script src="https://gtg.samsungapps.com/gsinstant-sdk/gsinstant.0.46.js"></script>
  <script src="https://img.samsungapps.com/gsinstant-sdk/iapinstant.1.0.js"></script>
  <script src="./wk-gameapi.min.js"></script>
</head>
<body>
<canvas id="game"></canvas>
<script>
window.addEventListener('load', async () => {
  const api = await WKGameApi.init({ appKey: 'YOUR_APP_KEY', platform: new WKGameApi.WKSamsungPlatform() })
  await loadAssets((p) => api.setLoadingProgress(p))
  await api.auth.login()
  if (api.iap.supported) await api.iap.restore(grantItem)
  api.platform.onAccountChange(() => api.platform.restart())
  await api.start()
  startGame(api)
})
async function grantItem(purchase) { /* 아이템 지급 + 저장 */ }
</script>
</body>
</html>

새 플랫폼 어댑터 ​

WKBasePlatform을 상속해 getLoginProof·purchase·consume·showAd 등을 구현해요. 서버에도 같은 id의 어댑터가 필요하니 웹젠케이 운영 담당자와 상의하세요.

© WEBZEN K. All rights reserved.