init framework
This commit is contained in:
8
demo/template/runtime/native_loader.js
Normal file
8
demo/template/runtime/native_loader.js
Normal file
@@ -0,0 +1,8 @@
|
||||
require("launcher/native_require.js");
|
||||
|
||||
egret_native.egtMain = function () {
|
||||
egret_native.nativeType = "native";
|
||||
|
||||
egret_native.egretInit();
|
||||
egret_native.egretStart();
|
||||
};
|
||||
53
demo/template/runtime/native_require.js
Normal file
53
demo/template/runtime/native_require.js
Normal file
@@ -0,0 +1,53 @@
|
||||
var manifest = JSON.parse(egret_native.readFileSync("manifest.json"));
|
||||
var game_file_list = manifest.initial.concat(manifest.game);
|
||||
|
||||
var window = this;
|
||||
|
||||
egret_native.setSearchPaths([""]);
|
||||
|
||||
egret_native.requireFiles = function () {
|
||||
for (var key in game_file_list) {
|
||||
var src = game_file_list[key];
|
||||
require(src);
|
||||
}
|
||||
};
|
||||
|
||||
egret_native.egretInit = function () {
|
||||
if(egret_native.featureEnable) {
|
||||
//控制一些优化方案是否开启
|
||||
//Control whether some optimization options are open
|
||||
var result = egret_native.featureEnable({
|
||||
|
||||
});
|
||||
}
|
||||
egret_native.requireFiles();
|
||||
egret.dom = {};
|
||||
egret.dom.drawAsCanvas = function () {
|
||||
};
|
||||
};
|
||||
|
||||
egret_native.egretStart = function () {
|
||||
var option = {
|
||||
//以下为自动修改,请勿修改
|
||||
//The following is automatically modified, please do not modify
|
||||
//----auto option start----
|
||||
entryClassName: "Main",
|
||||
frameRate: 30,
|
||||
scaleMode: "fixedWidth",
|
||||
contentWidth: 640,
|
||||
contentHeight: 1136,
|
||||
showPaintRect: false,
|
||||
showFPS: false,
|
||||
fpsStyles: "x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9",
|
||||
showLog: false,
|
||||
logFilter: "",
|
||||
maxTouches: 2,
|
||||
textureScaleFactor: 1
|
||||
//----auto option end----
|
||||
};
|
||||
|
||||
egret.native.NativePlayer.option = option;
|
||||
egret.runEgret();
|
||||
egret_native.Label.createLabel("/system/fonts/DroidSansFallback.ttf", 20, "", 0);
|
||||
egret_native.EGTView.preSetOffScreenBufferEnable(true);
|
||||
};
|
||||
8
demo/template/runtime/runtime_loader.js
Normal file
8
demo/template/runtime/runtime_loader.js
Normal file
@@ -0,0 +1,8 @@
|
||||
require("launcher/native_require.js");
|
||||
|
||||
egret_native.egtMain = function () {
|
||||
egret_native.nativeType = "runtime";
|
||||
|
||||
egret_native.egretInit();
|
||||
egret_native.egretStart();
|
||||
};
|
||||
96
demo/template/web/index.html
Normal file
96
demo/template/web/index.html
Normal file
@@ -0,0 +1,96 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Egret</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="full-screen" content="true" />
|
||||
<meta name="screen-orientation" content="portrait" />
|
||||
<meta name="x5-fullscreen" content="true" />
|
||||
<meta name="360-fullscreen" content="true" />
|
||||
<style>
|
||||
html, body {
|
||||
-ms-touch-action: none;
|
||||
background: #888888;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="margin: auto;width: 100%;height: 100%;" class="egret-player"
|
||||
data-entry-class="Main"
|
||||
data-orientation="auto"
|
||||
data-scale-mode="fixedWidth"
|
||||
data-frame-rate="30"
|
||||
data-content-width="640"
|
||||
data-content-height="1136"
|
||||
data-show-paint-rect="false"
|
||||
data-multi-fingered="2"
|
||||
data-show-fps="false" data-show-log="false"
|
||||
data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
|
||||
</div>
|
||||
<script>
|
||||
var loadScript = function (list, callback) {
|
||||
var loaded = 0;
|
||||
var loadNext = function () {
|
||||
loadSingleScript(list[loaded], function () {
|
||||
loaded++;
|
||||
if (loaded >= list.length) {
|
||||
callback();
|
||||
}
|
||||
else {
|
||||
loadNext();
|
||||
}
|
||||
})
|
||||
};
|
||||
loadNext();
|
||||
};
|
||||
|
||||
var loadSingleScript = function (src, callback) {
|
||||
var s = document.createElement('script');
|
||||
s.async = false;
|
||||
s.src = src;
|
||||
s.addEventListener('load', function () {
|
||||
s.parentNode.removeChild(s);
|
||||
s.removeEventListener('load', arguments.callee, false);
|
||||
callback();
|
||||
}, false);
|
||||
document.body.appendChild(s);
|
||||
};
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', './manifest.json?v=' + Math.random(), true);
|
||||
xhr.addEventListener("load", function () {
|
||||
var manifest = JSON.parse(xhr.response);
|
||||
var list = manifest.initial.concat(manifest.game);
|
||||
loadScript(list, function () {
|
||||
/**
|
||||
* {
|
||||
* "renderMode":, //Engine rendering mode, "canvas" or "webgl"
|
||||
* "audioType": 0 //Use the audio type, 0: default, 2: web audio, 3: audio
|
||||
* "antialias": //Whether the anti-aliasing is enabled in WebGL mode, true: on, false: off, defaults to false
|
||||
* "calculateCanvasScaleFactor": //a function return canvas scale factor
|
||||
* }
|
||||
**/
|
||||
egret.runEgret({ renderMode: "webgl", audioType: 0, calculateCanvasScaleFactor:function(context) {
|
||||
var backingStore = context.backingStorePixelRatio ||
|
||||
context.webkitBackingStorePixelRatio ||
|
||||
context.mozBackingStorePixelRatio ||
|
||||
context.msBackingStorePixelRatio ||
|
||||
context.oBackingStorePixelRatio ||
|
||||
context.backingStorePixelRatio || 1;
|
||||
return (window.devicePixelRatio || 1) / backingStore;
|
||||
}});
|
||||
});
|
||||
});
|
||||
xhr.send(null);
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user