未名人的flash rpg地图编辑器代码分析(1)

 (1)地图编辑器的创建对话框

    按下创建按钮后,首先要

   newSceneWindow = TitleWindow(PopUpManager.createPopUp(this, NewScene, true));
   //                PopUpManager.bringToFront(newSceneWindow);
    newSceneWindow.addEventListener( MapEditEvent.NEW_SCENE, newScene);  //把按钮ok按下后的事件创好

(2)弹出编辑对话框,把设置的值赋给父application的成员变量

    this.parentApplication.sceneId = this.sceneId.text;
    
    this.parentApplication.mapWidth = this.mapWidthText.text;
    this.parentApplication.mapHeight = this.mapHeightText.text;
    this.parentApplication.tilePixelWidth = this.tileWidthText.text;
    this.parentApplication.tilePixelHeight = this.tileHeightText.text;
    

   (3)最后确定后 ,激发这个MapEditEvent.NEW_SCENE事件

   this.dispatchEvent(new MapEditEvent(MapEditEvent.NEW_SCENE));

 

(4)地图移动

  鼠标右键按下,记录鼠标按下位置

private function hRightMouseDownCanvas(event:MouseEvent):void
   {
    if (this.mapLayer == null) return;
    
    this.rightMouseDowned = true; //鼠标右键按下
    
    //鼠标按下时所在像素点
    this.mousePointOldX = event.stageX;
    this.mousePointOldY = event.stageY;
   
   }

 当移动鼠标的时候,就要开始动作,同时改变各个层的地图坐标

if (this.rightMouseDowned == true) //鼠标右键按下
    {
     //移动地图
     this.mapLayer.x = this.mapLayer.x + event.stageX - this.mousePointOldX;
     this.mapLayer.y = this.mapLayer.y + event.stageY - this.mousePointOldY;
     this.mousePointOldX = event.stageX;
     this.mousePointOldY = event.stageY;
     
     this.gridLayer.x = this.mapLayer.x;
     this.gridLayer.y = this.mapLayer.y;
     this.walkableLayer.x = this.mapLayer.x;
     this.walkableLayer.y = this.mapLayer.y;
     this.buildingLayer.x = this.mapLayer.x;
     this.buildingLayer.y = this.mapLayer.y;
    }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值