简单的对对碰小游戏源码

package com.data
{
 import mx.controls.Button;

 /**
  * 格子数据
  **/
 public class DataItem extends Button
 {
  public static const TYPES:Array = [1, 2, 3, 4, 5, 6, 7];
  public static const WIDTH:uint = 50;
  public static const HEIGHT:uint = 50;
  
  private var _type:int;
  private var _px:int;
  private var _py:int;
  private var _initXY:Boolean;
  public function DataItem()
  {
   super();
   this.width = DataItem.WIDTH;
   this.height = DataItem.HEIGHT;
   this._initXY = false;
   select();
  }

  public function get type():int
  {
   return _type;
  }

  public function set type(value:int):void
  {
   _type = value;
   this.label = String(value);
  }

  public function isSame(item:DataItem):Boolean{
   return this._type == item._type;
  }

  public function get px():int
  {
   return _px;
  }

  public function set px(value:int):void
  {
   _px = value;
  }

  public function get py():int
  {
   return _py;
  }

  public function set py(value:int):void
  {
   _py = value;
  }

  public function get initXY():Boolean
  {
   return _initXY;
  }

  public function set initXY(value:Boolean):void
  {
   _initXY = value;
  }
  
  public function select(sign:Boolean = false):void{
   if(sign){
    this.alpha = 1;
   }else{
    this.alpha = 0.2;
   }
  }

 }
}

-------------------------------------------------------------------------

 

package com.data
{
 import flash.events.Event;
 import flash.events.MouseEvent;
 import flash.events.TimerEvent;
 import flash.utils.Timer;
 
 import mx.containers.Panel;

 /**L
  * 对对碰容器管理
  **/
 public class DataManager extends Panel
 {
  private var _data:Array;
  private var _rows:uint;
  private var _cols:uint;
  private var _deletes:Array;
  
  private var _selectItem:DataItem;
  private var _timer:Timer;
  private var _item1:DataItem;
  private var _item2:DataItem;
  private var _active:Boolean = false;
  private var _unselect:Boolean = false;
  
  public function DataManager(rows:uint, cols:uint)
  {
   super();
   this.layout = "absolute";
   _data = new Array();
   _rows = rows;
   _cols = cols;
   _deletes = new Array();
   
   var i:uint = 0;
   var j:uint = 0;
   var item:DataItem = null;<

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值