源码分享Html5捕鱼达人源码分享
Posted java小白逆袭之路
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了源码分享Html5捕鱼达人源码分享相关的知识,希望对你有一定的参考价值。
html5捕鱼达人源码分享!!!
本资源整理自互联网,仅供学习交流使用,请勿商用,坚持每日分享一套Java学习资源干货,一起提高,一起进步!!!
Html5捕鱼达人源码分享:
项目截图:
部分源码:
(function(){
var ns = Q.use("fish"), game = ns.game;
var FishManager = ns.FishManager = function(container)
{
this.fishPool = [];
this.poolSize = game.params.num || 100;
this.minNumFishScreen = this.poolSize >> 1;
this.maxNumFishScreen = this.poolSize;
this.enabled = true;
this.container = container;
this.fishes = [];
this.makeCounter = game.fps * 2;
this.initPool();
};
FishManager.prototype.initPool = function()
{
for(var i = 0; i < this.poolSize; i++)
{
var fish = new ns.Fish(ns.R.fishTypes[1]);
fish.getDrawable(game.stage.context);
this.fishPool[i] = fish;
}
};
FishManager.prototype.update = function()
{
if(!this.enabled) return;
for(var i = 0; i < this.fishes.length; i++)
{
var fish = this.fishes[i];
if(fish.captured)
{
this.fishes.splice(i, 1);
i--;
}else if(fish.isOutOfScreen())
{
if(fish.hasShown || fish.changeDirCounter < -game.fps*10)
{
this.fishes.splice(i, 1);
this.fishPool.push(fish);
fish.parent.removeChild(fish);
i--;
}
}else if(!fish.hasShown)
{
fish.hasShown = true;
}
}
if(--this.makeCounter <= 0)
{
this.makeCounter = this.fishes.length < this.minNumFishScreen ? game.fps*2 : game.fps*3;
this.makeFish();
}
};
FishManager.prototype.makeFish = function()
{
if(this.fishes.length >= this.poolSize) return;
//random fish type
var len = ns.R.fishTypes.length;
var chance = Math.random() * len >> 0;
var index = Math.random() * chance + 1 >> 0;
var type = ns.R.fishTypes[index];
var num = Math.random() * type.mixin.maxNumGroup + 1 >> 0;
if(num > this.fishPool.length) num = this.fishPool.length;
if(num <= 0) return;
//initialize fish properties
var group = this.fishPool.splice(0, num), cy = game.height >> 1;
var typeWidth = type.frames[0].rect[2], typeHeight = type.frames[0].rect[3];
var sx = Math.random() > 0.5 ? -typeWidth : game.width + typeWidth;
var sy = Math.random()* 200 + (game.height >> 1) - 100 >> 0;
var speed = Math.random()*(type.mixin.maxSpeed - type.mixin.minSpeed) + type.mixin.minSpeed;
var degree = (Math.random() * 20 - 10 >> 0);
if(sx > 0) degree += 180;
//make fish alive
for(var i = 0; i < num; i++)
{
var fish = group[i];
fish.setType(type);
fish.moving = true;
fish.canTurning = false;
fish.hasShown = false;
fish.captured = false;
fish.speed = speed;
fish.changeDirection(degree);
this.fishes.push(fish);
this.container.addChild(fish);
}
ns.FishGroup.setRandomPatten(group, sx, sy);
};
})();
Html5捕鱼达人源码分享:
(回复 捕鱼达人 获取)
感谢您的阅读,也欢迎您把喜欢的文章分享给更多的朋友一起阅读!您的“在看”就是对小编最大的支持!
以上是关于源码分享Html5捕鱼达人源码分享的主要内容,如果未能解决你的问题,请参考以下文章
网狐6603 cocos2dx 棋牌捕鱼休闲类游戏《李逵捕鱼》手机端完整源码分析及分享
重回童年的经典系列 |捕鱼达人小游戏来啦~ 有源码下载文末送书