Wortal SDK for Defold
설치하기
Wortal SDK를 Defold library dependency로 추가하기
사용방법
광고
인터스티셜 광고는 레벨을 달성하거나 전환하는 사이사이에 표시할 수 있습니다.
-- 플레이어가 레벨을 달성.
wortal.ads_show_interstitial("next", "NextLevel", pause_game, resume_game)
-- 플레이어가 게임을 일시 중지했습니다.
wortal.ads_show_interstitial("pause", "PausedGame", pause_game, resume_game)
-- 플레이어가 인앱 결제 페이지에 접속합니다.
wortal.ads_show_interstitial("browse", "BrowseShop", pause_audio, resume_audio)
리워드 광고는 플레이어가 동영상 광고를 끝까지 시청하는 등의 조건을 충족할 경우 보상을 제공하는 광고 유형입니다. 반드시 플레이어에게 알리고 허락을 받은 후 표시해야 합니다.
-- 이 예시에서는 광고 조건 달성 여부와 상관없이 게임이 진행됩니다.
-- 예: 플레이어는 광고를 시청하여 보너스 코인을 획득할 수 있지만, 그 결과와 상관없이 게임은 계속 진행됩니다.
wortal.ads_show_rewarded("BonusCoins", pause_game, resume_game, skip_bonus, add_bonus_coins)
-- 이 예시에서는 광고 조건 달성 여부와 관련하여 게임이 진행됩니다.
-- 예: 게임오버 시 플레이어는 광고를 시청하여 부활할 수 있지만, 광고를 건너뛰면 해당 레벨을 잃게 됩니다.
wortal.ads_show_rewarded("ReviveAndContinue", pause_audio, resume_audio, end_game, continue_game)
참고: 플레이어는 adViewed 콜백을 통해서만 보상을 받을 수 있습니다.
애널리틱스
Wortal의 애널리틱스 API를 활용하여 게임 이벤트를 추적하고 플레이어의 게임 내 활동을 파악할 수 있습니다. 이 데이터는 Wortal의 대시보드에서 확인할 수 있습니다.
-- 레벨 시작을 기록합니다.
wortal.analytics_log_level_start("Level 3")
-- 레벨의 끝을 기록합니다. 이름이 일치하면 게임 시간을 기록한다.
// logLevelStart()의 마지막 호출명
wortal.analytics_log_level_end("Level 3", "100", 1)
-- 플레이어의 게임 내 선택 행동을 기록합니다. 게임의 밸런스를 맞추는 데 도움이 됩니다.
// 그리고 플레이어가 많이 이용하는 콘텐츠를 파악할 수 있습니다.
wortal.analytics_log_game_choice("Character", "Blue")
업적
Achievements API는 플레이어의 게임 내 진행 상황을 추적하는 데 사용됩니다. 특정 작업을 완료하거나 특정 마일스톤에 도달하면 잠금 해제할 수 있습니다.
-- 업적 잠금 해제하기.
wortal.achievements_unlock_achievement("achievement-123", function(self, success, error)
popup.success_check(success, "Success!", "Error")
end)
-- 플레이어가 획득한 업적 목록을 가져옵니다.
wortal.achievements_get_achievements(function(self, achievements, error)
popup.success_check(achievements, prettify(json.decode(achievements)), "Error")
end)
컨텍스트
컨텍스트 API는 플레이어끼리 연결하여 게임 섹션 참여, 콘텐츠 공유, 메시지 교환 등에 활용할 수 있습니다.
-- 친구를 게임에 초대하기.
local payload = {
image = 'data:base64image',
text = 'Invite text',
cta = 'Play',
data = { exampleData: 'yourData' },
}
wortal.context_invite(json.encode(payload), function(self, success, error)
popup.success_check(success, "Success!", "Error")
end)
-- 이 게임의 활동을 친구들과 공유하세요.
local payload = {
image = 'data:base64image',
text = 'Share text',
cta = 'Play',
data = { exampleData: 'yourData' },
}
wortal.context_share(json.encode(payload), function(self, shareResult, error)
popup.success_check(shareResult, shareResult, "Error")
end)
인앱결제
인앱 결제(IAP) API는 플랫폼에서 게임 내 트랜잭션이 발생할 때 사용됩니다. 이 프로세스는 플레이 중인 플랫폼에 따라 다르지만, IP는 동일합니다.
-- 플레이어가 구매할 수 있는 아이템 목록 확인.
wortal.iap_get_catalog(function(self, catalog, error)
popup.success_check(catalog, prettify(json.decode(catalog)), "Catalog failed")
end)
-- 아이템 구매하기.
local purchaseConfig = {
productID = "my.product.id"
}
wortal.iap_make_purchase(json.encode(purchaseConfig), function(self, purchase, error)
popup.success_check(purchase, prettify(json.decode(purchase)), "Purchase failed")
end)
리더보드
리더보드 API를 활용하면 플랫폼의 리더보드 기능에 접근할 수 있습니다. 플레이어들의 점수를 추적하고 순위를 매길 수 있습니다.
-- 상위 10위 안에 든 리더보드를 획득할 수 있다.
wortal.leaderboard_get_entries("global", 10, 0, function(self, entries, error)
popup.success_check(entries, prettify(json.decode(entries)), "Leaderboard get entries failed")
end)
-- 플레이어의 점수를 리더보드에 추가합니다.
wortal.leaderboard_send_entry("global", 250, "details", function(self, entry, error)
popup.success_check(entry, prettify(json.decode(entry)), "Leaderboard add failed")
end)
알림
Notifications API는 플레이어에게 알림을 보내는 데 사용됩니다. 플레이어에게 게임 내 이벤트를 알리거나 다시 플레이하도록 유도하는 데 사용할 수 있습니다.
-- 플레이어에게 보낼 알림을 예약합니다.
local payload = {
title = "Your energy is full!",
body = "Come back and play again.",
mediaURL: "https://example.com/image.png",
label: "resources-full",
scheduleInterval: 300
}
wortal.notifications_schedule(json.encode(payload), function(self, result, error)
popup.success_check(result, prettify(json.decode(result)), "Notification schedule failed")
end)
-- 예약된 알림을 취소합니다.
wortal.notifications_cancel("notification-123", function(self, success, error)
print(success)
end)
플레이어
현재 플레이어에 대한 자세한 내용은 Player API에서 확인할 수 있습니다.
-- 플레이어의 이름을 가져옵니다.
local name = wortal.player_get_name()
-- 플레이어의 친구 중 게임을 해본 적이 있는 사람들의 목록을 가져옵니다.
local payload = {
filter = "ALL",
size = 20,
hoursSinceInvitation = 4,
}
wortal.player_get_connected_players(json.encode(payload), function(self, players, error)
popup.success_check(players, prettify(json.decode(players)), "Error")
end)
세션
현재 세션 상태에 대한 자세한 내용은 Session API에서 확인할 수 있습니다.
-- 게임이 시작된 진입점을 얻는다.
wortal.session_get_entry_point(function(self, entryPoint, error)
popup.success_check(entryPoint, entryPoint, "Error")
end)
통계
Stats API는 플레이어의 게임 내 통계를 추적하는 데 사용됩니다.
-- 게임에서 플레이어의 진행 상황을 추적합니다.
wortal.stats_post_stats("level 1", 3, function(self, success, error)
popup.success_check(success, "Success!", "Error")
end)
-- 플레이어의 통계를 가져옵니다.
wortal.stats_get_stats("level 1", function(self, stats, error)
popup.success_check(stats, prettify(json.decode(stats)), "Error")
end)
토너먼트
Tournament API는 게임의 토너먼트를 생성하고 관리하는 데 사용됩니다.
-- 토너먼트 생성하기.
local payload = {
initialScore: 100,
config: {
title: "Level 1 Tournament",
},
data: {
level: 1,
},
};
wortal.tournament_create(json.encode(payload)), function(self, tournament, error)
popup.success_check(tournament, prettify(json.decode(tournament)), "Error")
end)
-- 토너먼트에서 점수를 기록한다.
wortal.tournament_post_score(200), function(self, success, error)
popup.success_check(success, "Success!", "Error")
end)