划线让一个小黑人的游戏过的游戏

小黑人闯天关3
介绍:小黑人JACK又来到了一个新的充满未知危险的世界,这个世界不但充满了机关陷阱,而且错综复杂,JACK能否闯过这个如天关般的世界?
玩家通过←↑→键来控制方向。分享:梦想一定要有,万一实现了呢~@~
1.使用框架以及插件:
1.1.jquery.js(如果有必要,这个可以不用的,页面中很少用到了dom操作)
1.2.lufylegend.js(一个canvas框架,写的还不错,只不过,在使用这个框架后,有些绑定在dom身上的事件就不能用了,就必须得用lufylegend里面的方式处理事件,这个地方还是有点麻烦的)
2.1.index.html
&!DOCTYPE html&
&title&&/title&
&meta charset="UTF-8" /&
&meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0" name="viewport"&
&link href="jiathis_share.css" type="text/css" rel="stylesheet" /&
&style type="text/css"&
-webkit-user-select:
body, html {
margin:0; padding:0; height:100%; width:100%; overflow: background:#D5D5D5;
#mylegend {
width:100%; height:100%; overflow: display:
#currentLevel {
position: display:-webkit- -webkit-box-orient: -webkit-box-pack: -webkit-box-align: z-index:10; width:320 height:200 left:50%; top:50%; margin-left:-160 margin-top:-100 font-size:1.2
#currentLevel .levelInfo {
text-align: margin-top:1.5
#currentLevel .title {
#currentLevel p {
margin:0; padding:0; font-weight: text-align:
#currentLevel .value {
font-style: color:
#currentLevel .startBtnContainer {
height:2 width:100%; text-align:
#currentLevel .startBtn {
width:50%; height:2 color:# background-color:#5bc0 border-color:#46b8 border-radius:5 text-decoration: display:
margin: margin-top:0.5 line-height:2
#currentLevel .startBtn:hover {
color:# background-color:#31b0d5; border-color:#269
#jiathis_style a {
display:inline-
#jiathis_style {
text-align: margin-top:0.5
#qrcodeContainer {
position: width:100%; height:100%; left:0 top:0 z-index:11; background:#D5D5D5; display:
#qrcodeContainer .container {
display:-webkit- -webkit-box-orient: -webkit-box-pack: -webkit-box-align:
position: left:0 top:0 width:100%; height:100%;
#qrcodeContainer p {
margin:0; padding:0; color: font-size:1.1 line-height:2 text-align: position:
#qrcodeContainer img {
width:100%; height: max-width:320
#qrcodeContainer a.close {
display:inline- width:50 height:1.2 line-height:1.2 border:0.5 color:# font-style: text-align: margin-left:50
font-size:0.8 position: text-decoration: background:
&div id="currentLevel"&
&p class="title"&点击屏幕,制造长梯,让小人爬的越远越好,注意:不要太长哟~@~&/p&
&p class="levelInfo"&当前等级:&em class="value"&0&/em&&/p&
&div class="startBtnContainer"&&a href="javascript:void(0)" class="startBtn" &开始游戏&/a&&/div&
&div class="jiathis_style_24x24" id="jiathis_style"&
&a target="_blank" class="jiathis_button_qzone"&&span class="jtico jtico_qzone"&&/span&&/a&
&a target="_blank" class="jiathis_button_tsina"&&span class="jtico jtico_tsina"&&/span&&/a&
&a target="_blank" class="jiathis_button_tqq"&&span class="jtico jtico_tqq"&&/span&&/a&
&a class="jiathis_button_weixin"&&span class="jtico jtico_weixin"&&/span&&/a&
&a target="_blank"class="jiathis_button_renren"&&span class="jtico jtico_renren"&&/span&&/a&
&div id="qrcodeContainer"&
&div class="container"&
&p &扫一扫分享到微信&a href="javascript:void(0)" class="close"&关闭&/a&&/p&
&img src="qrcode.png" /&
&div id="mylegend"&loading……&/div&
&script type="text/javascript" src="jquery.min.js" &&/script&
&script type="text/javascript" src="lufylegend.min.js" &&/script&
&script type="text/javascript" src="index.js" &&/script&
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
&!DOCTYPE html&&html& &head&
&title&&/title&
&meta charset="UTF-8" /&
&meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0" name="viewport"&
&link href="jiathis_share.css" type="text/css" rel="stylesheet" /&
&style type="text/css"&
-webkit-user-select:none;
body, html {
margin:0; padding:0; height:100%; width:100%; overflow:hidden; background:#D5D5D5;
#mylegend {
width:100%; height:100%; overflow:hidden; display:none;
#currentLevel {
position:fixed; display:-webkit-box; -webkit-box-orient:horizontal; -webkit-box-pack:center; -webkit-box-align:center; z-index:10; width:320px; height:200px; left:50%; top:50%; margin-left:-160px; margin-top:-100px; font-size:1.2rem;
#currentLevel .levelInfo {
text-align:center; margin-top:1.5rem;
#currentLevel .title {
color:gray;
#currentLevel p {
margin:0; padding:0; font-weight:bolder; text-align:center;
#currentLevel .value {
font-style:normal; color:orange;
#currentLevel .startBtnContainer {
height:2rem; width:100%; text-align:center;
#currentLevel .startBtn {
width:50%; height:2rem; color:#fff; background-color:#5bc0de; border-color:#46b8da; border-radius:5px; text-decoration:none; display:block;
margin:auto; margin-top:0.5rem; line-height:2rem;
#currentLevel .startBtn:hover {
color:#fff; background-color:#31b0d5; border-color:#269abc;
#jiathis_style a {
display:inline-block;
#jiathis_style {
text-align:center; margin-top:0.5rem;
#qrcodeContainer {
position:fixed; width:100%; height:100%; left:0px; top:0px; z-index:11; background:#D5D5D5; display:none;
#qrcodeContainer .container {
display:-webkit-box; -webkit-box-orient:horizontal; -webkit-box-pack:center; -webkit-box-align:center;&&position:absolute; left:0px; top:0px; width:100%; height:100%;
#qrcodeContainer p {
margin:0; padding:0; color:gray; font-size:1.1rem; line-height:2rem; text-align:center; position:relative;
#qrcodeContainer img {
width:100%; height:auto; max-width:320px;
#qrcodeContainer a.close {
display:inline-block; width:50px; height:1.2rem; line-height:1.2rem; border:0.5px solid gray; color:#fff; font-style:normal; text-align:center; margin-left:50px;
font-size:0.8rem; position:relative; text-decoration:none; background:gray;
&/style& &/head& &body&
&div id="currentLevel"&
&p class="title"&点击屏幕,制造长梯,让小人爬的越远越好,注意:不要太长哟~@~&/p&
&p class="levelInfo"&当前等级:&em class="value"&0&/em&&/p&
&div class="startBtnContainer"&&a href="javascript:void(0)" class="startBtn" &开始游戏&/a&&/div&
&div class="jiathis_style_24x24" id="jiathis_style"&
&a target="_blank" class="jiathis_button_qzone"&&span class="jtico jtico_qzone"&&/span&&/a&
&a target="_blank" class="jiathis_button_tsina"&&span class="jtico jtico_tsina"&&/span&&/a&
&a target="_blank" class="jiathis_button_tqq"&&span class="jtico jtico_tqq"&&/span&&/a&
&a class="jiathis_button_weixin"&&span class="jtico jtico_weixin"&&/span&&/a&
&a target="_blank"class="jiathis_button_renren"&&span class="jtico jtico_renren"&&/span&&/a&
&div id="qrcodeContainer"&
&div class="container"&
&p &扫一扫分享到微信&a href="javascript:void(0)" class="close"&关闭&/a&&/p&
&img src="qrcode.png" /&
&div id="mylegend"&loading……&/div&
&script type="text/javascript" src="jquery.min.js" &&/script&
&script type="text/javascript" src="lufylegend.min.js" &&/script&
&script type="text/javascript" src="index.js" &&/script& &/body&&/html&
2.2.index.js
JavaScript
var STATIC = {
width: window.innerWidth,
height: window.innerHeight,
blockHeight: 70,
NORMAL: 0,
POSTER_GROWING: 1,
POSTER_PULLDOWN: 2,
MONSTER_RUNNING: 3,
MONSTER_CALCU: 4,
GO_NEXT_STEP: 5,
FAIL_ANIMATE: 6,
POSTER_WIDTH: 2,
MONSTER_WIDTH: 15,
MONSTER_HEIGHT: 35,
MONSTER_BACK_STEP: 1,
NEXT_STEP_SIZE: 4,
BACKGROUND_COLOR: "#d5d5d5",
BLOCK_RANDOM_MAX_WIDTH: 15,
BLOCK_MIN_WIDTH: 10,
BLOCK_RANDOM_OFFLEFT_MAX_WIDTH: 40,
BLOCK_OFFSET_MIN_WIDTH: 20,
var currentState =
var blockL
var blockList = [];
var poster = {};
var growingCount = 0;
var destX = 0;
var currentLevel = 0;
var currentLevelDom = $("#currentLevel");
var startBtnContainer = $(".startBtnContainer");
var qrcodeContainer = $("#qrcodeContainer");
var mylegendDom = $("#mylegend");
var jiathis_style_weixin = $("#jiathis_style .jiathis_button_weixin");
var jiathis_style_qq = $("#jiathis_style .jiathis_button_qzone");
var jiathis_style_sina = $("#jiathis_style .jiathis_button_tsina");
var jiathis_style_qqt = $("#jiathis_style .jiathis_button_tqq");
var jiathis_style_renren = $("#jiathis_style .jiathis_button_renren");
function touchStart() {
if(currentState !== STATIC.NORMAL) {
currentState = STATIC.POSTER_GROWING;
growingCount = 0;
function touchEnd() {
switch(currentState) {
case STATIC.POSTER_GROWING:
currentState = STATIC.POSTER_PULLDOWN;
function jumpToWeixin() {
qrcodeContainer.show();
function hideWeixin() {
qrcodeContainer.hide();
function jumpToQQ() {
location.href = "http://sns./cgi-bin/qzshare/cgi_qzshare_onekey?url=http%3A%2F%%2Fdemo%2Fdemo_877%23jtss-qzone&title=%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F&pics=&summary=%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F";
function jumpToSina() {
location.href = "/share/share.php?title=%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F%20%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F&url=http%3A%2F%%2Fdemo%2Fdemo_877%23jtss-tsina&source=bookmark&appkey=&pic=&ralateUid=";
function jumpToQQT() {
location.href = "http://share.v./index.php?c=share&a=index&title=%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F%20%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F&url=http%3A%2F%%2Fdemo%2Fdemo_877%23jtss-tqq&appkey=ce15ea612a5c29f82f080&site=&pic=";
function jumpToRenRen() {
location.href = "/dialog/share?resourceUrl=http%3A%2F%%2Fdemo%2Fdemo_877%23jtss-renren&srcUrl=http%3A%2F%%2Fdemo%2Fdemo_877%23jtss-renren&title=%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F&pic=&description=%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F";
init(50, "mylegend", STATIC.width, STATIC.height, main);
function main() {
var loader = new LLoader();
loader.PLETE, initGame);
loader.load("monster.png", "bitmapData");
function initGame(event) {
backLayer = new LSprite();
backLayer.width = STATIC.
backLayer.height = STATIC.
backLayer.x = backLayer.y = 0;
backLayer.graphics.drawRect(0, STATIC.BACKGROUND_COLOR, [0, 0, STATIC.width, STATIC.height], true, STATIC.BACKGROUND_COLOR);
addChild(backLayer);
blockLayer = new LSprite();
blockLayer.graphics.drawRect(0, "#ff0000", [0, 0, STATIC.width-2, STATIC.blockHeight], false, "black");
blockLayer.x = 0;
blockLayer.y = STATIC.height - STATIC.blockHeight - 1;
backLayer.addChild(blockLayer);
poster = {
sprite: posterSprite,
y: STATIC.height - STATIC.blockHeight
var posterSprite = new LSprite();
posterSprite.width = STATIC.POSTER_WIDTH;
backLayer.addChild(posterSprite);
poster.sprite = posterS
// monster
monster = new LSprite();
var bitmapdata = new LBitmapData(event.target);
var bitmap = new LBitmap(bitmapdata);
monster.addChild(bitmap);
monster.width = STATIC.MONSTER_WIDTH;
monster.height = STATIC.MONSTER_HEIGHT;
backLayer.addChild(monster);
backLayer.addEventListener(LEvent.ENTER_FRAME, onframe);
backLayer.addEventListener(LMouseEvent.MOUSE_DOWN, touchStart);
backLayer.addEventListener(LMouseEvent.MOUSE_UP, touchEnd);
LEvent.addEventListener(startBtnContainer.find(".startBtn").get(0), "mouseup", function () {
createBlockList();
resetGameEnv();
startBtnContainer.hide();
currentState = STATIC.NORMAL;
mylegendDom.show();
updateLevel();
LEvent.addEventListener(startBtnContainer.find(".startBtn").get(0), "touchend", function () {
createBlockList();
resetGameEnv();
startBtnContainer.hide();
currentState = STATIC.NORMAL;
mylegendDom.show();
updateLevel();
LEvent.addEventListener(qrcodeContainer.find(".close").get(0), "mouseup", hideWeixin);
LEvent.addEventListener(qrcodeContainer.find(".close").get(0), "touchend", hideWeixin);
LEvent.addEventListener(jiathis_style_weixin.get(0), "mouseup", jumpToWeixin);
LEvent.addEventListener(jiathis_style_weixin.get(0), "touchend", jumpToWeixin);
LEvent.addEventListener(jiathis_style_qq.get(0), "mouseup", jumpToQQ);
LEvent.addEventListener(jiathis_style_qq.get(0), "touchend", jumpToQQ);
LEvent.addEventListener(jiathis_style_sina.get(0), "mouseup", jumpToSina);
LEvent.addEventListener(jiathis_style_sina.get(0), "touchend", jumpToSina);
LEvent.addEventListener(jiathis_style_qqt.get(0), "mouseup", jumpToQQT);
LEvent.addEventListener(jiathis_style_qqt.get(0), "touchend", jumpToQQT);
LEvent.addEventListener(jiathis_style_renren.get(0), "mouseup", jumpToRenRen);
LEvent.addEventListener(jiathis_style_renren.get(0), "touchend", jumpToRenRen);
function createBlockList() {
var curBlockWidth = 0;
var index = 0;
while(curBlockWidth & STATIC.width) {
var block = {
width: Math.round(Math.random()*STATIC.BLOCK_RANDOM_MAX_WIDTH+STATIC.BLOCK_MIN_WIDTH),
height: STATIC.blockHeight,
left: !curBlockWidth ? curBlockWidth : Math.round(Math.random()*STATIC.BLOCK_RANDOM_OFFLEFT_MAX_WIDTH+STATIC.BLOCK_OFFSET_MIN_WIDTH),
sprite: null,
index: index
var blockSprite = new LSprite();
blockSprite.graphics.drawRect(0, "#ff0000", [0, 0, block.width, STATIC.blockHeight], true, "black");
blockSprite.x = curBlockWidth + block.
blockSprite.y = 0;
blockSprite.width = block.
blockSprite.height = STATIC.blockH
blockLayer.addChildAt(blockSprite, index);
block.sprite = blockS
blockList.push(block);
curBlockWidth += (block.width + block.left);
function resetGameEnv() {
currentState =
currentLevel = 0;
poster.x = 2;
poster.y = STATIC.height - STATIC.blockH
poster.sprite.graphics.clear();
poster.sprite.x = poster.x;
poster.sprite.y = poster.y;
for(var i=0, len=blockList. i& i++) {
var block = blockList[i];
blockLayer.removeChild(block.sprite);
blockList = [];
createBlockList();
monster.x = blockList[0].left + blockList[0].width - STATIC.MONSTER_WIDTH - STATIC.MONSTER_BACK_STEP;
monster.y = STATIC.height - STATIC.blockHeight - STATIC.MONSTER_HEIGHT;
function updateLevel() {
currentLevelDom.find(".value").text(currentLevel);
function onframe() {
switch(currentState) {
case STATIC.POSTER_GROWING:
growingCount++;
poster.height = growingCount*2;
poster.sprite.x = blockList[0].left + blockList[0].
poster.sprite.rotate = 180;
poster.sprite.graphics.drawRect(0, "#fff", [0, 0, STATIC.POSTER_WIDTH, poster.height], true, "#fff");
case STATIC.POSTER_PULLDOWN:
poster.sprite.rotate = -90;
currentState = STATIC.MONSTER_RUNNING;
destX = poster.height + monster.x + monster.width/2;
case STATIC.MONSTER_RUNNING:
monster.x += 2;
if(monster.x & destX) {
currentState = STATIC.MONSTER_CALCU;
case STATIC.MONSTER_CALCU:
var failed =
for(var i=0, len=blockList. i& i++) {
var block = blockList[i];
if((monster.x + monster.width/2) &= (block.sprite.x) && monster.x &= (block.sprite.x + block.width - monster.width/2)) {
monster.x = block.sprite.x + block.width - STATIC.MONSTER_WIDTH - STATIC.MONSTER_BACK_STEP;
if(failed) {
currentState = STATIC.FAIL_ANIMATE;
poster.sprite.height = 0;
poster.sprite.graphics.clear();
currentState = STATIC.GO_NEXT_STEP;
currentLevel++;
updateLevel();
case STATIC.GO_NEXT_STEP:
var block2 = blockList[1];
var block =
var curLastBlock =
for(var i=0, len=blockList. i& i++) {
var block = blockList[i];
block.sprite.x -= STATIC.NEXT_STEP_SIZE;
monster.x -= STATIC.NEXT_STEP_SIZE;
if(block2.sprite.x &= 0) {
var offsetX = -block2.sprite.x;
for(var i=0, len=blockList. i& i++) {
block = blockList[i];
block.sprite.x += offsetX;
// 重绘阻碍物
block.sprite.graphics.clear();
block.sprite.graphics.drawRect(0, "#ff0000", [0, 0, block.width, STATIC.blockHeight], true, "black");
block.left += offsetX;
block.index -= 1;
block2.left = 0;
monster.x = block2.left + block2.width - STATIC.MONSTER_WIDTH - STATIC.MONSTER_BACK_STEP;
// 重置弹出的块数据为最后一个
block = blockList.shift();
block.width = Math.round(Math.random()*STATIC.BLOCK_RANDOM_MAX_WIDTH+STATIC.BLOCK_MIN_WIDTH);
block.left = Math.round(Math.random()*STATIC.BLOCK_RANDOM_OFFLEFT_MAX_WIDTH+STATIC.BLOCK_OFFSET_MIN_WIDTH);
block.index = blockList.
curLastBlock = blockList[blockList.length - 1];
block.sprite.x = curLastBlock.sprite.x + curLastBlock.width + block.
block.sprite.graphics.drawRect(0, "#ff0000", [0, 0, block.width, STATIC.blockHeight], true, "black");
blockList.push(block);
currentState = STATIC.NORMAL;
case STATIC.FAIL_ANIMATE:
var posterFinished =
var monsterFinished =
if(poster.sprite.rotate & 0) {
poster.sprite.rotate += 5;
posterFinished =
if(monster.y & (STATIC.height - STATIC.MONSTER_HEIGHT)) {
monster.y += 5;
monsterFinished =
if(monsterFinished && posterFinished) {
currentState = STATIC.RESET;
case STATIC.RESET:
startBtnContainer.show();
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
var STATIC = { width: window.innerWidth, height: window.innerHeight, blockHeight: 70, NORMAL: 0, POSTER_GROWING: 1, POSTER_PULLDOWN: 2, MONSTER_RUNNING: 3, MONSTER_CALCU: 4, GO_NEXT_STEP: 5, FAIL_ANIMATE: 6, RESET: 7, POSTER_WIDTH: 2, MONSTER_WIDTH: 15, MONSTER_HEIGHT: 35, MONSTER_BACK_STEP: 1, NEXT_STEP_SIZE: 4, BACKGROUND_COLOR: "#d5d5d5", BLOCK_RANDOM_MAX_WIDTH: 15, BLOCK_MIN_WIDTH: 10, BLOCK_RANDOM_OFFLEFT_MAX_WIDTH: 40, BLOCK_OFFSET_MIN_WIDTH: 20,};var currentState = null;var backLayer;var blockLayer;var blockList = [];var poster = {};var growingCount = 0;var destX = 0;var monster;var currentLevel = 0;var currentLevelDom = $("#currentLevel");var startBtnContainer = $(".startBtnContainer");var qrcodeContainer = $("#qrcodeContainer");var mylegendDom = $("#mylegend");var jiathis_style_weixin = $("#jiathis_style .jiathis_button_weixin");var jiathis_style_qq = $("#jiathis_style .jiathis_button_qzone");var jiathis_style_sina = $("#jiathis_style .jiathis_button_tsina");var jiathis_style_qqt = $("#jiathis_style .jiathis_button_tqq");var jiathis_style_renren = $("#jiathis_style .jiathis_button_renren"); function touchStart() { if(currentState !== STATIC.NORMAL) {
return; }& currentState = STATIC.POSTER_GROWING; growingCount = 0;}function touchEnd() { switch(currentState) {
case STATIC.POSTER_GROWING:
currentState = STATIC.POSTER_PULLDOWN;
break; }}function jumpToWeixin() { qrcodeContainer.show();}function hideWeixin() { qrcodeContainer.hide();}function jumpToQQ() { location.href = "http://sns./cgi-bin/qzshare/cgi_qzshare_onekey?url=http%3A%2F%%2Fdemo%2Fdemo_877%23jtss-qzone&title=%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F&pics=&summary=%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F";}function jumpToSina() { location.href = "/share/share.php?title=%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F%20%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F&url=http%3A%2F%%2Fdemo%2Fdemo_877%23jtss-tsina&source=bookmark&appkey=&pic=&ralateUid=";}function jumpToQQT() { location.href = "http://share.v./index.php?c=share&a=index&title=%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F%20%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F&url=http%3A%2F%%2Fdemo%2Fdemo_877%23jtss-tqq&appkey=ce15ea612a5c29f82f080&site=&pic=";}function jumpToRenRen() { location.href = "/dialog/share?resourceUrl=http%3A%2F%%2Fdemo%2Fdemo_877%23jtss-renren&srcUrl=http%3A%2F%%2Fdemo%2Fdemo_877%23jtss-renren&title=%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F&pic=&description=%E5%93%87%EF%BC%8C%E6%88%91%E7%AB%9F%E7%84%B6%E5%8D%87%E7%BA%A7%E5%88%B0%E4%BA%86200%E7%BA%A7%EF%BC%8C%E4%BD%A0%E6%95%A2%E8%AF%95%E8%AF%95%E4%B9%88%EF%BC%9F";}init(50, "mylegend", STATIC.width, STATIC.height, main); function main() { var loader = new LLoader();&&&&loader.addEventListener(LEvent.COMPLETE, initGame); &&&&loader.load("monster.png", "bitmapData");}function initGame(event) { backLayer = new LSprite(); backLayer.width = STATIC.width; backLayer.height = STATIC.height; backLayer.x = backLayer.y = 0; backLayer.graphics.drawRect(0, STATIC.BACKGROUND_COLOR, [0, 0, STATIC.width, STATIC.height], true, STATIC.BACKGROUND_COLOR); addChild(backLayer); blockLayer = new LSprite(); blockLayer.graphics.drawRect(0, "#ff0000", [0, 0, STATIC.width-2, STATIC.blockHeight], false, "black"); blockLayer.x = 0; blockLayer.y = STATIC.height - STATIC.blockHeight - 1; backLayer.addChild(blockLayer); // poster poster = {
sprite: posterSprite,
y: STATIC.height - STATIC.blockHeight }; var posterSprite = new LSprite(); posterSprite.width = STATIC.POSTER_WIDTH; backLayer.addChild(posterSprite); poster.sprite = posterSprite; // monster monster = new LSprite(); var bitmapdata = new LBitmapData(event.target);&&&&&&var bitmap = new LBitmap(bitmapdata);&&&&monster.addChild(bitmap); monster.width = STATIC.MONSTER_WIDTH; monster.height = STATIC.MONSTER_HEIGHT; backLayer.addChild(monster); backLayer.addEventListener(LEvent.ENTER_FRAME, onframe); backLayer.addEventListener(LMouseEvent.MOUSE_DOWN, touchStart); backLayer.addEventListener(LMouseEvent.MOUSE_UP, touchEnd);
LEvent.addEventListener(startBtnContainer.find(".startBtn").get(0), "mouseup", function () {
createBlockList();
resetGameEnv();
startBtnContainer.hide();
currentState = STATIC.NORMAL;
mylegendDom.show();
updateLevel(); }); LEvent.addEventListener(startBtnContainer.find(".startBtn").get(0), "touchend", function () {
createBlockList();
resetGameEnv();
startBtnContainer.hide();
currentState = STATIC.NORMAL;
mylegendDom.show();
updateLevel(); }); LEvent.addEventListener(qrcodeContainer.find(".close").get(0), "mouseup", hideWeixin); LEvent.addEventListener(qrcodeContainer.find(".close").get(0), "touchend", hideWeixin); LEvent.addEventListener(jiathis_style_weixin.get(0), "mouseup", jumpToWeixin); LEvent.addEventListener(jiathis_style_weixin.get(0), "touchend", jumpToWeixin); LEvent.addEventListener(jiathis_style_qq.get(0), "mouseup", jumpToQQ); LEvent.addEventListener(jiathis_style_qq.get(0), "touchend", jumpToQQ); LEvent.addEventListener(jiathis_style_sina.get(0), "mouseup", jumpToSina); LEvent.addEventListener(jiathis_style_sina.get(0), "touchend", jumpToSina); LEvent.addEventListener(jiathis_style_qqt.get(0), "mouseup", jumpToQQT); LEvent.addEventListener(jiathis_style_qqt.get(0), "touchend", jumpToQQT); LEvent.addEventListener(jiathis_style_renren.get(0), "mouseup", jumpToRenRen); LEvent.addEventListener(jiathis_style_renren.get(0), "touchend", jumpToRenRen);}function createBlockList() { var curBlockWidth = 0; var index = 0; while(curBlockWidth & STATIC.width) {
var block = {
width: Math.round(Math.random()*STATIC.BLOCK_RANDOM_MAX_WIDTH+STATIC.BLOCK_MIN_WIDTH),
height: STATIC.blockHeight,
left: !curBlockWidth ? curBlockWidth : Math.round(Math.random()*STATIC.BLOCK_RANDOM_OFFLEFT_MAX_WIDTH+STATIC.BLOCK_OFFSET_MIN_WIDTH),
sprite: null,
index: index
var blockSprite = new LSprite();
blockSprite.graphics.drawRect(0, "#ff0000", [0, 0, block.width, STATIC.blockHeight], true, "black");
blockSprite.x = curBlockWidth + block.left;
blockSprite.y = 0;
blockSprite.width = block.width;
blockSprite.height = STATIC.blockHeight;
blockLayer.addChildAt(blockSprite, index);
block.sprite = blockSprite;
blockList.push(block);
curBlockWidth += (block.width + block.left); }}function resetGameEnv() { currentState = null; currentLevel = 0; // poster poster.x = 2; poster.y = STATIC.height - STATIC.blockHeight; poster.sprite.graphics.clear(); poster.sprite.x = poster.x; poster.sprite.y = poster.y; for(var i=0, len=blockList.length; i&len; i++) {
var block = blockList[i];
blockLayer.removeChild(block.sprite); } blockList = []; createBlockList(); monster.x = blockList[0].left + blockList[0].width - STATIC.MONSTER_WIDTH - STATIC.MONSTER_BACK_STEP; monster.y = STATIC.height - STATIC.blockHeight - STATIC.MONSTER_HEIGHT;}function updateLevel() { currentLevelDom.find(".value").text(currentLevel);}function onframe() { switch(currentState) {
case STATIC.POSTER_GROWING:
growingCount++;
poster.height = growingCount*2;
poster.sprite.x = blockList[0].left + blockList[0].width;
poster.sprite.rotate = 180;
poster.sprite.graphics.drawRect(0, "#fff", [0, 0, STATIC.POSTER_WIDTH, poster.height], true, "#fff");
case STATIC.POSTER_PULLDOWN:
poster.sprite.rotate = -90;
currentState = STATIC.MONSTER_RUNNING;
destX = poster.height + monster.x + monster.width/2;
case STATIC.MONSTER_RUNNING:
monster.x += 2;
if(monster.x & destX) {
currentState = STATIC.MONSTER_CALCU;
case STATIC.MONSTER_CALCU:
var failed = true;
for(var i=0, len=blockList.length; i&len; i++) {
var block = blockList[i];
if((monster.x + monster.width/2) &= (block.sprite.x) && monster.x &= (block.sprite.x + block.width - monster.width/2)) {
monster.x = block.sprite.x + block.width - STATIC.MONSTER_WIDTH - STATIC.MONSTER_BACK_STEP;
failed = false;
if(failed) {
currentState = STATIC.FAIL_ANIMATE;
poster.sprite.height = 0;
poster.sprite.graphics.clear();
currentState = STATIC.GO_NEXT_STEP;
currentLevel++;
updateLevel();
case STATIC.GO_NEXT_STEP:
var block2 = blockList[1];
var block = null;
var curLastBlock = null;
for(var i=0, len=blockList.length; i&len; i++) {
var block = blockList[i];
block.sprite.x -= STATIC.NEXT_STEP_SIZE;
monster.x -= STATIC.NEXT_STEP_SIZE;&
if(block2.sprite.x &= 0) {
var offsetX = -block2.sprite.x;
for(var i=0, len=blockList.length; i&len; i++) {
block = blockList[i];
block.sprite.x += offsetX;
// 重绘阻碍物
block.sprite.graphics.clear();
block.sprite.graphics.drawRect(0, "#ff0000", [0, 0, block.width, STATIC.blockHeight], true, "black");
block.left += offsetX;
block.index -= 1;
block2.left = 0;
monster.x = block2.left + block2.width - STATIC.MONSTER_WIDTH - STATIC.MONSTER_BACK_STEP;
// 重置弹出的块数据为最后一个
block = blockList.shift();
block.width = Math.round(Math.random()*STATIC.BLOCK_RANDOM_MAX_WIDTH+STATIC.BLOCK_MIN_WIDTH);
block.left = Math.round(Math.random()*STATIC.BLOCK_RANDOM_OFFLEFT_MAX_WIDTH+STATIC.BLOCK_OFFSET_MIN_WIDTH);
block.index = blockList.length;
curLastBlock = blockList[blockList.length - 1];
block.sprite.x = curLastBlock.sprite.x + curLastBlock.width + block.left;
block.sprite.graphics.drawRect(0, "#ff0000", [0, 0, block.width, STATIC.blockHeight], true, "black");
blockList.push(block);
currentState = STATIC.NORMAL;
case STATIC.FAIL_ANIMATE:
var posterFinished = false;
var monsterFinished = false;
if(poster.sprite.rotate & 0) {
poster.sprite.rotate += 5;
posterFinished = true;
if(monster.y & (STATIC.height - STATIC.MONSTER_HEIGHT)) {
monster.y += 5;
monsterFinished = true;
if(monsterFinished && posterFinished) {
currentState = STATIC.RESET;
case STATIC.RESET:
startBtnContainer.show();
2.3.lufylegend.min.js(略)下载地址:
转载请注明: &
or分享 (0)}

我要回帖

更多关于 小黑人游戏 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信