小鸟展开html5,html5 欢快的小鸟 小游戏源码(flappy-bird)typescript开发

【实例简介】flappy-bird 欢快的小鸟

【实例截图】

db7ce9ae12ef828a1a400dc88f498649.gif

26ea7ac0bc98191546f5b07160434c8f.png

【核心代码】

Egret

html, body {

-ms-touch-action: none;

background: #888888;

padding: 0;

border: 0;

margin: 0;

height: 100%;

}

data-entry-class="Main"

data-orientation="auto"

data-scale-mode="fixedNarrow"

data-frame-rate="30"

data-content-width="1080"

data-content-height="1920"

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">

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);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值