Laya Tutorial-Docking the Douyin Mini Game SDK (10 minutes to master)

Video presentation

LAYA docking with Douyin games (10 minutes to master)

Speech:

The content of this section is about: Laya docking with Douyin game platform

Function points include:
banner ads, rewarded videos, interstitial ads, channel game list display, video recording, video sharing, version update

LAYA version 2.5, development language ts

We use the official 2d case as a template for platform docking

Open the video case

We added 3 buttons to the template, start the game, double the score, record and share

Insert picture description here

Import TS library to scirpt directory

banner ad

The game runs, and the banner advertisement is opened when the game ends

GameControl.ts

onEnable() and stopGame() enter the following code

BannerAndVideo1.OpenBanner(this, null);

Interstitial ads
stopGame() increase the code
BannerAndVideo1.CreateInterstitialAd();//Interstitial ads

Real machine running results
Insert picture description here
Insert picture description here

Click on more games to display the game box
GameUI.ts

moregameClcik() { //sdk BannerAndVideo1.ShowGameList(); } Real machine running result




Insert picture description here

Clear the advertising component when the game starts
startGame()
//sdk
BannerAndVideo1.Clear();

Game screen recording
Start
TTmgr.instance.recordStart();
End screen recording

stopGame
TTmgr.instance.recordStop(this, (isok) => { });

Share screen recording
Insert picture description here
Motivated video, double the score
gameui.ts
scoreMul2Click()
BannerAndVideo1.ShowVideo(this, this.onvideoEnd)

onvideoEnd(isok) {
    console.log(this);
    if (isok) {
        Platform.ShowToast('奖励X2');
        this._score *= 2;
        this.scoreLbl.changeText("分数:" + this._score);
    }
    else
        Platform.ShowToast('看完视频才有奖励');
}

Quick version update
GameControl.ts
Insert picture description here
Insert picture description here

Perform a video demonstration of the final result

Download ByteDance Developer Tools, the corresponding version of the tutorial is 1.9.0
https://microapp.bytedance.com/docs/zh-CN/mini-app/develop/developer-instrument/developer-instrument-update-and- download
Insert picture description here

Perform a real-device demonstration

Explain the advertising component

ByteDance developer documentation
https://microapp.bytedance.com/docs/zh-CN/mini-game/develop/open-capacity/ads/tt-create-banner-ad/

In order to be able to successfully test on the real machine, the developer must prepare the advertising ID and APPID and the ID of the game list to jump

The configuration of the jump of the game list The
ID required by the configuration component
game.json configuration whitelist

Insert picture description here
Insert picture description here
Configure appid
Insert picture description here

Compatibility processing will be done before API calls. For example, interstitial ads only support Android headlines
Insert picture description here

When opening the banner, because the advertising component is loaded asynchronously, canshowbanner is used to restrict whether to display or not,
mainly to avoid displaying after closing the advertisement

Insert picture description here

It should be noted that the platform supported by the banner.
Insert picture description here
The reason for the failure of screen recording and sharing: the screen recording time cannot be less than 3 seconds.
Insert picture description here

The course uses the 1.9.0 bytebeat developer tool and 2.5 version of LAYA, so some functions need to be tested on a real machine

The LAYA docking Douyin SDK course is explained here, thanks for watching

Course materials can be downloaded in the Q group
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/koljy111/article/details/108410659