Code Monkey home page Code Monkey logo

egretweixinjsbridge's Introduction

EgretWeixinJSBridge

本项目是 Egret 的非官方扩展 - 微信 JavaScript Bridge 接口

本项目的JavaScript源代码来源于 这里 ,本项目未修改其源代码,只是将其添加了 .d.ts 描述文件,并调整为 egret 第三方组件库的标准结构。感谢原作者的辛勤劳动!

使用方法

在 Egret 的下个版本中会提供自动化的模块添加机制,但如果开发者现在就有需求使用此模块,请按照以下方式添加到游戏中

  • 复制 bin/WeixinAPI.js 到 游戏项目中的 launcher/WeixinAPI.js
  • 复制 libs/WeixinAPI.d.ts 到 游戏项目中的 libs/WeixinAPI.d.ts
  • 在游戏项目的 index.htmlrelease.html 中添加 <script src="launcher/WeixinAPI.js" async="false"></script>
  • 参考 GameApp.ts 中的调用方式,实现开发者的分享需求

   //  当游戏结束,开发者引导用户去分享时调用此代码

  WeixinApi.ready(function(api:WeixinApi){

            alert("WeixinAPI Ready!!");

            var info:WeixinShareInfo = new WeixinShareInfo();
            info.title = "HelloEgret";
            info.desc = "欢迎使用Egret";
            info.link = "www.egret-labs.org";
//                        info.imgUrl = "";


            api.shareToFriend(info);
            api.shareToTimeline(info);
        })




上述代码只是在用户分享到好友、朋友圈时用自定义的分享内容,并不是实现直接弹出分享界面

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.