欢迎来到程序小院
奔跑吧男子汉
玩法:移动摇杆控制人物,躲过黑衣人的追击,喝下饮料,燃烧小宇宙,我要反杀,快去奔跑吧男子汉^^。
开始游戏https://www.ormcc.com/play/gameStart/250
html
<div style="position:relative;" id="gameDiv"></div>
css
body {
text-align: center;
background: #000000;
padding: 0;
border: 0;
margin: 0;
height: 100%;
}
html {
-ms-touch-action: none; /* Direct all pointer events to JavaScript code. */
overflow: hidden;
}
canvas {
display: block;
position: absolute;
margin: 0 auto;
padding: 0;
border: 0;
}
js
function setStageSize() {
if (/iphone/i.test(navigator.userAgent)) {
window["client"] = "iphone";
} else {
window["client"] = "android";
}
/*全屏适配*/
var winHeight;
var winWidth;
if (document.documentElement && document.documentElement.clientHeight &&
document.documentElement.clientWidth) {
winHeight = document.documentElement.clientHeight;
winWidth = document.documentElement.clientWidth;
} else {
winHeight = window.innerHeight;
winWidth = window.innerWidth;
}
var GameWin;
if (window["client"] == "iphone") {
GameWin = {w: 640, h: 1136}; //i6苹果分辨率
} else {
GameWin = {w: 320, h: 568};//安卓客户端考虑到性能,将分辨率降为i6分辨率的一半
}
var Gper = GameWin.h / GameWin.w;
var per = winHeight / winWidth;
if (per < Gper) {
window["stage_width"] = GameWin.h / per;
window["stage_height"] = GameWin.h;
} else if (per >= Gper) {
window["stage_width"] = GameWin.w;
window["stage_height"] = GameWin.w * per;
}
egret.StageDelegate.getInstance().setDesignSize(window["stage_width"],
window["stage_height"]);
if (window["client"] == "android") {
window["stage_width"] *= 2;
window["stage_height"] *= 2;
}
}
egret_h5.startGame = function () {
var context = egret.MainContext.instance;
context.touchContext = new egret.HTML5TouchContext();
context.deviceContext = new egret.HTML5DeviceContext();
context.netContext = new egret.HTML5NetContext();
setStageSize();//调用上面写好的方法
context.stage = new egret.Stage();
var scaleMode = egret.MainContext.deviceType == egret.MainContext.DEVICE_MOBILE ?
egret.StageScaleMode.SHOW_ALL : egret.StageScaleMode.NO_SCALE;
context.stage.scaleMode = egret.StageScaleMode.SHOW_ALL;
//WebGL is a Egret's beta property. It's off by default.
//WebGL是egret的Beta特性,默认关闭
var rendererType = 0;
if (rendererType == 1) {// egret.WebGLUtils.checkCanUseWebGL()) {
console.log("Use WebGL mode");
context.rendererContext = new egret.WebGLRenderer();
}
else {
context.rendererContext = new egret.HTML5CanvasRenderer();
}
egret.MainContext.instance.rendererContext.texture_scale_factor = 1;
context.run();
var rootClass;
if(document_class){
rootClass = egret.getDefinitionByName(document_class);
}
if(rootClass) {
var rootContainer = new rootClass();
if(rootContainer instanceof egret.DisplayObjectContainer){
context.stage.addChild(rootContainer);
}
else{
throw new Error("Document Class must be the subclass to egret.DisplayObjectContainer!");
}
}
else{
throw new Error("Document Class is not found!");
}
//处理屏幕大小改变
//implement for screen size change
var resizeTimer = null;
var doResize = function () {
context.stage.changeSize();
resizeTimer = null;
};
window.onresize = function () {
if (resizeTimer == null) {
resizeTimer = setTimeout(doResize, 300);
}
};
};
egret_h5 = {};
egret_h5.prefix = "";
egret_h5.loadScript = function (list, callback) {
var loaded = 0;
var loadNext = function () {
egret_h5.loadSingleScript(egret_h5.prefix + list[loaded], function () {
loaded++;
if (loaded >= list.length) {
callback();
}
else {
loadNext();
}
})
};
loadNext();
};
egret_h5.loadSingleScript = function (src, callback) {
var s = document.createElement('script');
if (s.hasOwnProperty("async")) {
s.async = false;
}
s.src = src;
s.addEventListener('load', function () {
s.parentNode.removeChild(s);
this.removeEventListener('load', arguments.callee, false);
callback();
}, false);
document.body.appendChild(s);
};
egret_h5.preloadScript = function (list, prefix) {
if (!egret_h5.preloadList) {
egret_h5.preloadList = [];
}
egret_h5.preloadList = egret_h5.preloadList.concat(list.map(function (item) {
return prefix + item;
}))
};
egret_h5.startLoading = function () {
var list = egret_h5.preloadList;
egret_h5.loadScript(list, egret_h5.startGame);
};
var meiriq_loading = (function() {
function meiriq_loading() {
this.msgArr = ['设计狮疯狂上色中…','攻城狮奋力敲出游戏代码…','产品汪吃力搬运页面元素…',
'小Q正在擦拭按钮…','游戏主角正在房间里化妆…','运营喵撰写得分文案中...','游戏正在空中赶过来…'];
this.currentIndex = 0;
this.onCreate();
}
meiriq_loading.prototype.onCreate = function() {
var content;
content = document.createElement('div');
content.setAttribute('id', 'meiriq-loading');
content.style.position = 'absolute';
content.style.width = '100%';
content.style.height = '100%';
content.style.top = '0';
content.style.textAlign = "center";
content.style.bottom = '0';
content.style.left = '0';
content.style.right = '0';
content.style.zIndex = 9999;
content.style.backgroundColor = '#ffffff';
content.innerHTML = '<img id="" style="position:absolute;bottom:30px;left:'+(
window.innerWidth/2 -35)+'px;" />';
document.body.appendChild(content);
};
meiriq_loading.prototype.changeMsg = function(){
var mp = document.getElementById('meiriq-loading-msg');
if(mp){
mp.innerHTML = this.msgArr[(this.currentIndex++)%7];
var self = this;
setTimeout(function(){
self.changeMsg();
},1000);
}
};
meiriq_loading.prototype.setProgress = function(current, total) {
};
meiriq_loading.prototype.finish = function() {
var elem;
return (elem = document.getElementById('meiriq-loading')).parentNode.
removeChild(elem);
};
return meiriq_loading;
})();
var loading = new meiriq_loading();
loading.changeMsg();
需要源码请关注添加好友哦^ ^
转载:欢迎来到本站,转载请注明文章出处
https://ormcc.com/