Giter VIP home page Giter VIP logo

cocos-to-playable-ad's Introduction

cocos-to-playable-ad

将 cocos creator 构建出来的 web-mobile 项目打包为 playable-ad 项目,即单 html 文件。 一些说明:

如何使用?

  • 开发环境:
    • macOs Cataline 10.15
    • node.js 12.9.0
    • cocos creator 2.1.3
    • Chrome 77
  • 输入:使用 cocos creator 构建出来的 web-mobile 项目文件夹。
  • 输出:index.html。
  • 使用方法:
    1. 将构建出来的 web-mobile 整个文件夹整个放入项目的 src 目录下。此时目录为:src/web-mobile/...
    2. 修改 src/web-mobile/main.js,注释掉 154 到 163 行,目的是不在代码中载入 project.js,而是在流程中载入。
    3. 在根目录下执行 npm run build,会显示流程执行过程以及相应的消耗时间。
    4. 点击输出文件 dist/index.html,检查在浏览器中是否显示正常。

核心算法

  • 将项目所依赖的资源读取并写入到 window.res,保存为 res.js。
  • 通过 cc.loader.addDownloadHandlers 修改资源载入方式,从 window.res 中载入资源,参考 new-res-loader.js。
  • 将 index.html 中所依赖的 css 和 js 文件,包括一些新的 js 文件写入到 html 文件本身。

依赖模块:

cocos-to-playable-ad's People

Contributors

fkworld avatar

Watchers

James Cloos avatar

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.