本文主要是介绍未名人的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;
}
这篇关于未名人的flash rpg地图编辑器代码分析(1)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!