欢迎来到程序小院
足球大师
玩法:点击鼠标开始足球从落下,再次点击鼠标进行踢球,根据足球落的高度进行踢球,
统计球被踢出的距离,赶紧去踢球吧^^。
开始游戏https://www.ormcc.com/play/gameStart/229
html
css
canvas{
width:100%;
height:100%;
}
#container{
position:absolute;
bottom:0;left:0;width:100%;height:100%;
}
js
var placedata=["农坛","丰体","天安门","天坛","鸟巢","南锣鼓巷","北海","永定门","五道口",
"西单","宣武门","马甸","雍和宫","颐和园","圆明园"];
var placepos=0;
var Main = {};
btGame.makePublisher(Main);
// 舞台宽高
Main.width = 720;
Main.height = 950;
// 地平线
Main.floorLine = 850;
// 路标间距
Main.guideDistance = Main.width;
Main.debug = false;
// 角度
Main.minAngle = 5;
Main.maxAngle = 30;
Main.randomAngle = 2; // 上下偏移角度
// 掉落时间
Main.fallingTime = 1100;
// 速度
Main.speed = 400;
// 舞台可视距离
Main.visibleDistance = 250;
// 最高份
Main.maxScore = (window.localStorage && +localStorage["zqdsMaxScore"]) || 0;
// 帧频
Main.fps = 40;
// 游戏开始界面
Main.startGame = function(){
var container = new createjs.Container();
container.addChild(new createjs.Bitmap(Resource.get("img/start.png")));
// 开始游戏
var beginGame = new createjs.Bitmap(Resource.get("img/startbtn.png"));
beginGame.setTransform(34, 750);
beginGame.cursor = "pointer";
beginGame.addEventListener("click", function(){
createjs.Tween.get(container, {loop: false})
.to({alpha: 0}, 300)
.call(function(){
Main.initGame();
});
});
container.addChild(beginGame);
// 更多游戏
var moreGame = new createjs.Bitmap(Resource.get("img/morebtn.png"));
moreGame.setTransform(377, 750);
moreGame.cursor = "pointer";
moreGame.addEventListener("click", function(){
dp_Ranking();
});
container.addChild(moreGame);
Main.stage.addChild(container);
}
// 游戏结束界面
Main.endGame = function(distance){
if(!Main.endContainer){
Main.endContainer = new createjs.Container();
}else{
Main.endContainer.removeAllEventListeners();
Main.endContainer.removeAllChildren();
}
var container = Main.endContainer;
container.alpha = 0;
container.addChild(new createjs.Bitmap(Resource.get("img/end.png")));
// 本次成绩
var text1 = new createjs.Text(
"本次距离: "+distance+" M", "bold 28pt Tahoma Helvetica Arial sans-serif", "#ffffff"
);
text1.textAlign = "center";
text1.x = Main.width / 2;
text1.y = 174;
container.addChild(text1);
var text2 = text1.clone(true);
text2.text = "最远距离: " + Main.maxScore + " M";
text2.y = 248;
container.addChild(text2);
var share = Main.getShareText(distance);
var text3 = text1.clone(true);
text3.text = share["tip"];
text3.font = "bold 24pt Tahoma Helvetica Arial sans-serif";
text3.textAlign = "center";
text3.y = 394;
container.addChild(text3);
// 再来一次
var again = new createjs.Bitmap(Resource.get("img/againbtn.png"));
again.setTransform(35, 623);
again.addEventListener("click", function(){
placepos=0;
createjs.Tween.get(container, {loop: false})
.to({y: -Main.height, alpha: 0}, 500, createjs.Ease.quintInOut)
.call(function(){
container.alpha = 1;
container.removeAllEventListeners();
container.removeAllChildren();
Main.reset.replay();
});
});
container.addChild(again);
// 通知好友
var notify = new createjs.Bitmap(Resource.get("img/notifybtn.png"));
notify.setTransform(376, 623);
notify.addEventListener("click", function(){
dp_share();
});
container.addChild(notify);
// 更多游戏
var more = new createjs.Shape();
more.graphics.beginFill("#ffffff").drawRect(0, 0, Main.width, 60);
more.alpha = 0.1;
more.y = 870;
more.addEventListener("click", function(){
dp_Ranking();
});
container.addChild(more);
Main.stage.addChild(container);
container.y = -Main.height;
createjs.Tween.get(container, {loop: false})
.to({y:0, alpha:1}, 500, createjs.Ease.quintInOut);
var pos=placepos-1;
if(pos<0){
pos=placedata.length-1;
}
dp_submitScore(distance,placedata[pos]);
}
Main.initStage = function(){
// 舞台已经有了,就不用再初始化了
if(!this.stage){
Main.stage = new createjs.Stage("canvas");
}
// Main.stage.enableMouseOver();
Main.stage.removeAllEventListeners();
Main.stage.removeAllChildren();
// 清空舞台
Main.stage.removeAllChildren();
Main.stage.removeAllEventListeners();
// 舞台大小
Main.stage.width = canvas.width = Main.width;
Main.stage.height = canvas.height = Main.height;
createjs.Ticker.addEventListener("tick", this.stage);
// 先加载资源
Resource.load();
Resource.queue.addEventListener("complete", function(){
// Main.startGame();
Main.startGame();
});
};
源码
需要源码请关注添加好友哦^ ^
转载:欢迎来到本站,转载请注明文章出处https://ormcc.com/