For the complete documentation index, see llms.txt. This page is also available as Markdown.

游戏内广告

All Out 允许开发者在游戏中向玩家展示广告

激励式

激励式广告是可选广告,玩家可以观看以在你的游戏中获得某些奖励。例如,你可以设置一个奖品转盘,玩家通过观看广告来旋转转盘,从而有机会在你的游戏中赢得额外金币或道具。

API 参考

Ads :: struct {
    prompt_rewarded_ad :: proc(
        player: Player,
        reward_id: string,
        title: string,
        description: string,
        texture: Texture_Asset
    );

    is_ad_showing :: proc() -> bool;
}

为每个奖励使用一个稳定的 reward_id 。只从 ao_ads_reward_handler授予奖励,它会在平台报告激励式广告已完成后运行:

show_coin_ad :: proc(player: Player) {
    if Ads.is_ad_showing() return;

    icon := get_asset(Texture_Asset, "ui/coin.png");
    Ads.prompt_rewarded_ad(
        player,
        "coins_100",
        "获得 100 枚金币",
        "观看广告以获得 100 枚金币。",
        icon
    );
}

ao_ads_reward_handler :: proc(player: Player, reward_id: string) -> bool {
    if reward_id != "coins_100" return false;

    Economy.deposit_currency(player, "Coins", 100);
    return true;
}

在使用此示例之前,请先注册该货币;参见 Economy. 返回 true 仅在奖励已发放后。若为未知 ID 或无法完成发放,则返回 false

插屏

插屏广告会在回合之间或游戏低活跃时段展示,以产生收入,但不会直接奖励玩家。

例如,你可以在《谋杀之谜》的每一轮结束后显示插屏广告,因为玩家本来就要等待下一轮开始。

最后更新于