Подключаем плагин для минимального прохождения на яндекс игр. Сам плагин - GitHub - indiesoftby/defold-yagames: YaGames is the Yandex.Games SDK implementation for the Defold game engine.
добавляем зависимость
Добавляем расширение: game.project → project → dependencies → плюсик и добавляем строчку.
https://github.com/indiesoftby/defold-yagames/archive/refs/tags/0.18.0.zip
Базовая настройка
Работа с main.collection
# ASSETS
- создать loading.script
- создать game.collection
# OUTLINE
Берем main.collection, в ней:
- создать го, называем loading
- созадем прокси коллекцию, называем game и выбираем созданную из assets game.colletion
- добавляем loading.script
Работа с game.collection
# ASSETS
- создать game.script
# OUTLINE
Берем game.collection, в ней:
- создать го, называем game
- добавляем game.script
-- game.script
function init(self)
print('game.collection loading')
end
-- loading.script
local yagames = require("yagames.yagames")
local function init_handler(self, err)
if err then
print("Something bad happened :(", err)
else
-- яндекс сдк готово
yagames.features_loadingapi_ready()
-- язык, иначе не пройти модерацию, необязательно дальше использовать
self.language = yagames.environment().i18n.lang
-- загрузка сцены
msg.post("#game", "load")
end
end
function init(self)
-- белый фон
msg.post("@render:", "clear_color", { color = vmath.vector4(255/255, 255/255, 255/255, 1) })
-- ввод
msg.post(".", "acquire_input_focus")
yagames.init(init_handler)
end
function on_message(self, message_id, message, sender)
-- для загрузки через msg.post game.collection
if message_id == hash("proxy_loaded") and sender == msg.url("#game") then
msg.post(sender, "init")
msg.post(sender, "enable")
msg.post(sender, "acquire_input_focus")
end
end
защищаем игру от копипаста на другой портал
local sitelock = require("yagames.sitelock")
-- Добавить свой сайт:
-- sitelock.add_domain("yourdomainname.com")
function init(self)
-- вставить в начало коллекци main
if html5 and sitelock.is_release_build() then
if not sitelock.verify_domain() then
-- Show warning and pause the game
-- return не позволит коду за ним запуститься
return
end
end
end

