RunoseAI Creator 3.8.3 is compatible with Station B's mini-game solution

Tutorial

  1. When building a WeChat mini-game, 原生代码打包模式 choose asmJS not to choose wasm or wasm+asmJS
  2. Download the plugin provided by Bi Station
  3. Pack

Okay, all the processes are completed, and the work is over~

However, you who love to think will ask, if I can’t choose wasm, won’t it be more stuck when I do more physics?

Yes, according to the documentation, there is indeed no way, but after further communication with the official (Battle), I found that the Android version of the B station mini game actually supports wasm. If it supports Android, then let’s go to Android first. Next, we will slightly modify it to make Android support wasm and iOS will not be affected

Support wasm

Reference article: How to handle RunoseAI 3.8 when it does not support the wasm platform but relies on WeChat mini-games , Here too, we need to modify Cocos’s wasm judgment of the WeChat mini-game platform and continue to modify this fileresources/3d/engine/pal/system-info/minigame/system-info.ts

// 添加一个判断条件

if (WECHAT && typeof WXWebAssembly === 'object') {

    return true;

}

After the modification is completed, follow the original steps and select the native code packaging mode as wasm+asmJS (the name is both in 3.8.5), so that the package that supports B station mini-games is ready.

But someone (yes, it was me) discovered that there is no order in which plugins are executed, causing plugin incompatibility (each of them modified the same file). What should I do?

With a little thought, you can find that the easiest way is to combine the two plug-ins into one, so let’s do it.

Transformation plugin

After testing (in fact, I directly looked at the source code of the B station plug-in, the conscientious plug-in, the source code is also provided~), I found that the adaptation of the B station plug-in actually did three things:

  1. Add adaptation file
  2. Modify the reference of the web-adapter file
  3. Join Startup Report

So we just need to implement these three things in our own plug-in, for example

  1. Modify the game.js of the main package
const dealBilibili = async function (dest: string) {

    // 修改 game.js

    const gameJsPath = join(dest, "game.js");

    let gameJsContent = readFileSync(gameJsPath, "utf-8");

    // 注释web-adapter

    const start = gameJsContent.indexOf("require('./web-adapter");

    if (start !== -1) {

        // 向前找到前一个分号

        let prevSemicolon = gameJsContent.lastIndexOf(';', start) + 1;

        // 向后找到后一个分号

        let nextSemicolon = gameJsContent.indexOf(';', start) + 1;

        if (prevSemicolon !== -1 && nextSemicolon !== -1) {

            // 删除这个区间的内容

            gameJsContent = gameJsContent.slice(0, prevSemicolon) + gameJsContent.slice(nextSemicolon);

        }

    }

    const jsPath = join(__dirname, '..', 'static', 'adapters', 'biligame', 'js');

    // 添加两个文件,原插件有更新机制,请注意

    copySync(join(jsPath, 'blapp-adapter-wasm-for-cocos-v3.js'), join(dest, 'blapp-adapter-wasm-for-cocos-v3.js'));

    copySync(join(jsPath, 'blapp-adapter-downgrade-for-cocos-v3.6-and-above.js'), join(dest, 'blapp-adapter-downgrade-for-cocos-v3.6-and-above.js'));

    gameJsContent = `

require('./blapp-adapter-wasm-for-cocos-v3.js');

require('./blapp-adapter-downgrade-for-cocos-v3.6-and-above.js');

    ` + gameJsContent;

    writeFileSync(gameJsPath, gameJsContent, 'utf-8');

    const files = readdirSync(dest);

    for (let i = 0; i < files.length; i++) {

        const file = files[i];

        if (file.startsWith('web-adapter.') && file.endsWith('.js')) {

            if ('web-adapter.js' == file) {

                break;

            }

            // 如果加了md5,文件名就要修改为web-adapter.js

            renameSync(join(dest, file), join(dest, 'web-adapter.js'));

            break;

        }

    }

}

  1. Because I redefined game.js, I need to add startup judgment to the real game.js
    if ('biligame' === platform) {

        // 下方添加launchSuccess();

        // 修改 game.js

        const gameJsPath = join(dest, "game.js");

        let gameJsContent = readFileSync(gameJsPath, "utf-8");

        gameJsContent += `

if(bl){bl.launchSuccess()};`;

        writeFileSync(gameJsPath, gameJsContent, 'utf-8');

    }

Well, at this point, this article has been successfully completed.

3 Likes

Does Bilibili support individual developers?

Is the B station mini game platform just starting? There is no option to publish to B station in RunoseAI yet

That’s why there is this document.

1 Like

Great, support. Hope RunoseAI can also support it officially. There are many game area up masters on B station. It should be helpful for the small game platform.

After adapting 3.8.4 to the B station mini-game, the system font is very strange. It is not the normal bold font in the mobile phone, and each word has mixed edges. Is it the same for you?

I checked the official website. Currently, individual developers are shown as “stay tuned”.