Skip to content

如何编写 sebind 的 TS 接口? #1

Description

@patrick-fu

看了文档和此示例项目,但只演示了运行时在 Console 里调用原生的 Demo.hello 函数。

我正在做一个原生 SDK 的 Cocos Creator TS 封装层接口以方便用户使用,想了解一下如何编写 sebind 的 TS 接口呢?

以这个 Demo 为例,native 有一个 hello_cocos.h 头文件

// hello_cocos.h
class Demo {
    public:
        Demo(const char *name);
std::string hello(const char *message);
    private:
std::string _name;
};

期望是编写一个类似于如下的文件(伪代码)从而用户可以在他们的业务代码里直接导入这个 ts 文件来使用这个原生接口,但不知道如何编写

// hello_cocos.ts
class Demo {
    hello(message: string);
}

希望能提供这样的示例,谢谢~😳

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions