Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions templates/alipay-mini-game/game.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require('./web-adapter');

<% if(polyfillsBundleFile) { %>
// Polyfills bundle.
require("<%= polyfillsBundleFile %>");
<% } %>

// SystemJS support.
window.self = window;
require("<%= systemJsBundleFile %>");

const importMap = require("<%= importMapFile%>").default;
System.warmup({
importMap,
importMapUrl: '<%= importMapFile%>',
defaultHandler: (urlNoSchema) => {
require('.' + urlNoSchema);
},
});

System.import('<%= applicationJs %>').then(({ Application }) => {
return new Application();
}).then((application) => {
return onApplicationCreated(application);
}).catch((err) => {
console.error(err);
});

function onApplicationCreated(application) {
return System.import('cc').then((cc) => {
require('./engine-adapter');
return application.init(cc);
}).then(() => application.start());
}
10 changes: 10 additions & 0 deletions templates/alipay-mini-game/game.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"screenOrientation": "landscape",
"networkTimeout": {
"request": 5000,
"connectSocket": 5000,
"download": 500000,
"upload": 5000
},
"showStatusBar": false
}
66 changes: 66 additions & 0 deletions templates/baidu-mini-game/game.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
globalThis.__baiduRequire = require; // FIX: require implementation in browserify conflicts with baidu webpack
require('./web-adapter');

<% if(polyfillsBundleFile) { %>
// Polyfills bundle.
require("<%= polyfillsBundleFile %>");
<% } %>

// SystemJS support.
require("<%= systemJsBundleFile %>");
// 这句只有百度需要,因为百度的 webpack 提供了假的 System
const System = globalThis.System;

// Adapt for IOS, swap if opposite
if (canvas) {
var _w = canvas.width;
var _h = canvas.height;
if (screen.width < screen.height) {
if (canvas.width > canvas.height) {
_w = canvas.height;
_h = canvas.width;
}
} else {
if (canvas.width < canvas.height) {
_w = canvas.height;
_h = canvas.width;
}
}
canvas.width = _w;
canvas.height = _h;
}

// Adjust initial canvas size
if (canvas && window.devicePixelRatio >= 2) {canvas.width *= 2; canvas.height *= 2;}

const importMap = require("<%= importMapFile%>").default;
System.warmup({
importMap,
importMapUrl: '<%= importMapFile%>',
defaultHandler: (urlNoSchema) => {
require('.' + urlNoSchema);
},
});

System.import('<%= applicationJs %>').then(({ Application }) => {
return new Application();
}).then((application) => {
return onApplicationCreated(application);
}).catch((err) => {
console.error(err);
});

function onApplicationCreated(application) {
return System.import('cc').then((cc) => {
require('./engine-adapter');

// post system info to open data context
swan.getOpenDataContext().postMessage({
type: 'engine',
event: 'systemInfo',
systemInfo: swan.getSystemInfoSync(),
});

return application.init(cc);
}).then(() => application.start());
}
11 changes: 11 additions & 0 deletions templates/baidu-mini-game/game.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"deviceOrientation": "landscape",
"openDataContext": "",
"networkTimeout":
{
"request": 5000,
"connectSocket": 5000,
"uploadFile": 5000,
"downloadFile": 500000
}
}
14 changes: 14 additions & 0 deletions templates/baidu-mini-game/project.swan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"appid": "",
"compileType": "game",
"libVersion": "1.0.0",
"bundle":
{
"exclude": ["node_moudules"],
"entry": "game.js",
"compilers": [
{
"type": "babel"
}]
}
}
105 changes: 105 additions & 0 deletions templates/bytedance-mini-game/game.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<% if (isUsePhysX) { %>
const systemInfo = tt.getSystemInfoSync();
// a hack way to load physics provide by bytedance
if (tt.getPhysx) {
tt.getPhysx({
success (physx) {
if (!physx) {
console.error('can not use native PhysX');
} else {
console.info('physics plugin load success, version=' + physx.getVersion());
GameGlobal.nativePhysX = physx;
}
loadCC();
},
fail () {
loadCC();
}
});
} else if (systemInfo.platform === 'android' && tt.getLoader && tt.getLoader()) {
const appid = "<%= appid %>";
const loader = tt.getLoader().loader;
loader.load('physics', appid, "token", message => {
if (message) {
console.error('[tt.loader]:' + message);
} else {
console.info('[tt.loader]: physics plugin load success, version=' + tt.getPhy().getVersion());
GameGlobal.nativePhysX = tt.getPhy();
}
loadCC();
})
} else {
loadCC();
}
<% } %>

<% if (!isUsePhysX) { %>
loadCC();
<% } %>

function loadCC() {
require('./web-adapter');

<% if(polyfillsBundleFile) { %>
// Polyfills bundle.
require("<%= polyfillsBundleFile %>");
<% } %>

// SystemJS support.
require("<%= systemJsBundleFile %>");

// Adapt for IOS, swap if opposite
if (canvas){
var _w = canvas.width;
var _h = canvas.height;
if (screen.width < screen.height) {
if (canvas.width > canvas.height) {
_w = canvas.height;
_h = canvas.width;
}
} else {
if (canvas.width < canvas.height) {
_w = canvas.height;
_h = canvas.width;
}
}
canvas.width = _w;
canvas.height = _h;
}

// Adjust initial canvas size
if (canvas && window.devicePixelRatio >= 2) {canvas.width *= 2; canvas.height *= 2;}

const importMap = require("<%= importMapFile%>").default;
System.warmup({
importMap,
importMapUrl: '<%= importMapFile%>',
defaultHandler: (urlNoSchema) => {
require('.' + urlNoSchema);
},
handlers: {
'plugin:': (urlNoSchema) => {
typeof requirePlugin === 'function' ? requirePlugin(urlNoSchema) : require(urlNoSchema);
},
'project:': (urlNoSchema) => {
require(urlNoSchema);
},
},
});

System.import('<%= applicationJs %>').then(({ Application }) => {
return new Application();
}).then((application) => {
return onApplicationCreated(application);
}).catch((err) => {
console.error(err);
});

function onApplicationCreated(application) {
return System.import('cc').then((cc) => {
require('./engine-adapter');
return application.init(cc);
}).then(() => { return application.start(); });
}

}
11 changes: 11 additions & 0 deletions templates/bytedance-mini-game/game.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"deviceOrientation": "portrait",
"showStatusBar": false,
"openDataContext": "",
"networkTimeout": {
"request": 5000,
"connectSocket": 5000,
"uploadFile": 5000,
"downloadFile": 500000
}
}
11 changes: 11 additions & 0 deletions templates/bytedance-mini-game/project.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"setting": {
"urlCheck": true,
"es6": false,
"postcss": true,
"minified": true,
"newFeature": true
},
"appid": "testappId",
"projectname": ""
}
8 changes: 8 additions & 0 deletions templates/fb-instant-games/fbapp-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"instant_games": {
"orientation": "PORTRAIT",
"override_web_orientation": "PORTRAIT",
"platform_version": "RICH_GAMEPLAY",
"navigation_menu_version": "NAV_FLOATING"
}
}
24 changes: 24 additions & 0 deletions templates/fb-instant-games/index-plugin.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<% if (webDebuggerSrc) { %>
<script src="<%=webDebuggerSrc%>"></script>
<script type="text/javascript">
// open web debugger console
window.VConsole && (window.vConsole = new VConsole());
</script>
<% } %>

<!-- Import fbinstant -->
<!-- <script src="https://connect.facebook.net/en_US/fbinstant.6.3.js"></script> -->
<script src="https://www.facebook.com/assets.php/en_US/fbinstant.latest.js"></script>

<!-- Polyfills bundle. -->
<script src="<%= polyfillsBundleFile %>" charset="utf-8"> </script>

<!-- SystemJS support. -->
<script src="<%= systemJsBundleFile %>" charset="utf-8"> </script>

<!-- Import map -->
<script src="<%= importMapFile%>" type="systemjs-importmap" charset="utf-8"> </script>

<script>
System.import('./<%= indexJsName %>').catch(function(err) { console.error(err); })
</script>
48 changes: 48 additions & 0 deletions templates/fb-instant-games/index.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">

<title>Cocos Creator | <%= projectName %></title>

<!--http://www.html5rocks.com/en/mobile/mobifying/-->
<meta name="viewport"
content="width=device-width,user-scalable=no,initial-scale=1,minimum-scale=1,maximum-scale=1,minimal-ui=true"/>

<!--https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html-->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="format-detection" content="telephone=no">

<!-- force webkit on 360 -->
<meta name="renderer" content="webkit"/>
<meta name="force-rendering" content="webkit"/>
<!-- force edge on IE -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="msapplication-tap-highlight" content="no">

<!-- force full screen on some browser -->
<meta name="full-screen" content="yes"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>

<!--fix fireball/issues/3568 -->
<!--<meta name="browsermode" content="application">-->
<meta name="x5-page-mode" content="app">

<!--<link rel="apple-touch-icon" href=".png" />-->
<!--<link rel="apple-touch-icon-precomposed" href=".png" />-->

<link rel="stylesheet" type="text/css" href="<%= cssUrl %>"/>

</head>
<body>
<div id="GameDiv" cc_exact_fit_screen="true">
<div id="Cocos3dGameContainer">
<canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="99"></canvas>
</div>
</div>
<%- include(cocosTemplate, {}) %>
</body>
</html>
29 changes: 29 additions & 0 deletions templates/fb-instant-games/index.js.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Application } from '<%= applicationJS %>';

const canvas = document.getElementById('GameCanvas');
const $p = canvas.parentElement;
const bcr = $p.getBoundingClientRect();
canvas.width = bcr.width;
canvas.height = bcr.height;

function topLevelImport (url) {
return System.import(url);
}

const application = new Application();

FBInstant.initializeAsync().then(function () {
FBInstant.setLoadingProgress(10);
return topLevelImport('cc');
}).then(function (engine) {
FBInstant.setLoadingProgress(50);
return application.init(engine);
}).then(function () {
FBInstant.setLoadingProgress(99);
return application.start();
}).then(function () {
FBInstant.setLoadingProgress(100);
return FBInstant.startGameAsync();
}).catch((err) => {
console.error(err);
});
Loading
Loading