快速业务通道

FLASH教程:as3实现的俄罗斯方块

作者 佚名技术 来源 服务器技术 浏览 发布时间 2012-07-07
=0):void {
  • var liveBoxsShadow:Array = new Array();
  • for (var i:int = 0; i < liveBoxs.length; i++ ) {
  • liveBoxsShadow = {x:liveBoxs.x,y:liveBoxs.y};
  • liveBoxs.x += x;
  • liveBoxs.y += y;
  • }
  • if (!isLive()) {
  • for (i = 0; i < liveBoxs.length;i++ ) {
  • liveBoxs ={x:liveBoxsShadow.x,y:liveBoxsShadow.y};
  • }
  • }
  • }
  • private function roll(b:Boolean = true):void {
  • var liveBoxsShadow:Array = new Array();
  • for (var i:int = 0; i < liveBoxs.length; i++ ) {
  • liveBoxsShadow = {x:liveBoxs.x,y:liveBoxs.y};
  • }
  • if (b) {
  • for (i = 1; i < liveBoxs.length;i++ ) {
  • var tempIX:int=liveBoxs.x;
  • liveBoxs.x = liveBoxs[0].x+liveBoxs.y-liveBoxs[0].y;
  • liveBoxs.y = liveBoxs[0].y -tempIX +liveBoxs[0].x;
  • }
  • }else {
  • for (i= 1; i < liveBoxs.length;i++ ) {
  • tempIX=liveBoxs.x;
  • liveBoxs.x = liveBoxs[0].x-liveBoxs.y+liveBoxs[0].y;
  • liveBoxs.y = liveBoxs[0].y +tempIX -liveBoxs[0].x;
  • }
  • }
  • if (!isLive()) {
  • for (i = 0; i < liveBoxs.length;i++ ) {
  • liveBoxs ={x:liveBoxsShadow.x,y:liveBoxsShadow.y};
  • }
  • }
  • }
  • private function update():void {
  • world.graphics.clear();
  • world.graphics.lineStyle(1, 0xffffff);
  • world.graphics.lineTo(xNum * w , 0);
  • world.graphics.lineTo(xNum * w ,yNum * w);
  • world.graphics.lineTo(0, yNum * w );
  • world.graphics.lineTo(0,0);
  • world.graphics.lineStyle();
  • for (var i:int = 0; i < yNum;i++ ) {
  • for (var j:int = 0; j < xNum;j++ ) {
  • if (deadBoxs[j] == 1) {
  • world.graphics.beginFill(0x123456);
  • world.graphics.drawRect(j * w, i * w, w, w);
  • }
  • }
  • }
  • var color:Number;
  • if (lives[0]==4) {
  • color = 0x00ffff;
  • }else if (lives[0]==1) {
  • color = 0xff0000;
  • }else if (lives[0]==2) {
  • color = 0x00ff00;
  • }else if (lives[0]==3) {
  • color=0x0000ff
  • }else {
  • color=0xffff00
  • }
  • for (i = 0; i < liveBoxs.length; i++ ) {
  • world.graphics.beginFill(color,0.9);
  • world.graphics.drawRect(liveBoxs.x*w,liveBoxs.y*w,w,w);
  • }
  • world.graphics.lineStyle(1, 0xffffff, 0.5);
  • for (i = 0; i < xNum-1;i++ ) {
  • world.graphics.moveTo(w * (i + 1), 0);
  • world.graphics.lineTo(w * (i + 1), w*yNum);
  • }
  • for (i = 0; i < yNum-1;i++ ) {
  • world.graphics.moveTo(0, w*(i+1));
  • world.graphics.lineTo(w * xNum , w*(i+1));
  • }
  • }
  • private function clickHandler(e:MouseEvent):void {
  • navigateToURL( new URLRequest ("http://space.flash8.net/space/?534614" ) );
  • }
  • private function timeHandler2(e:TimerEvent):void {
  • if (keyLeft) {
  • move(-1, 0);
  • }
  • if (keyRight) {
  • move(1, 0);
  • }
  • if (keyRollLeft) {
  • roll();
  • }
  • if (keyRollRight) {
  • roll(false);
  • }
  • }
  • private function timeHandler
  • 凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

    分享到: 更多

    Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

    地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

    电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

    《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号