Skip to content

Commit

Permalink
场景 全局 初始化 使用配置加载
Browse files Browse the repository at this point in the history
使用loadMax管理加载进度
  • Loading branch information
[email protected] committed Aug 18, 2013
1 parent b45b198 commit bd5adc0
Show file tree
Hide file tree
Showing 67 changed files with 245 additions and 149 deletions.
8 changes: 4 additions & 4 deletions TeamX_Moblie/.actionScriptProperties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<actionScriptProperties analytics="false" mainApplicationPath="TeamX_Test.as" projectUUID="1caf4326-d8be-4939-869e-b56b9d50430d" version="11">
<actionScriptProperties analytics="false" mainApplicationPath="TeamX_Moblie.as" projectUUID="1caf4326-d8be-4939-869e-b56b9d50430d" version="11">
<compiler additionalCompilerArguments="-locale en_US -swf-version=17" advancedTelemetry="true" autoRSLOrdering="true" copyDependentFiles="true" fteInMXComponents="false" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="false" htmlHistoryManagement="false" htmlPlayerVersionCheck="true" includeNetmonSwc="false" outputFolderPath="bin" removeUnusedRSL="true" sourceFolderPath="src" strict="true" targetPlayerVersion="0.0.0" useApolloConfig="true" useDebugRSLSwfs="true" useFlashSDK="true" verifyDigests="true" warn="true">
<compilerSourcePath/>
<libraryPath defaultLinkType="0">
Expand Down Expand Up @@ -53,7 +53,6 @@
<flashCatalyst validateFlashCatalystCompatibility="false"/>
<buildTargets>
<buildTarget buildTargetName="device" iosSettingsVersion="2" isCurrent="true" platformId="com.adobe.flexide.multiplatform.ios.platform" provisioningFile="Certificate/GODTest.mobileprovision" releasePackageType="ipa-ad-hoc">
<multiPlatformSettings enabled="true" hideAneLibSymbols="0" includePlatformLibs="false" platformID="com.adobe.flexide.multiplatform.ios.platform" reducedSizePackaging="false" version="1"/>
<airSettings airCertificatePath="Certificate/GODTest.p12" airTimestamp="true" anePathSet="true" version="1">
<airExcludes/>
<anePaths/>
Expand All @@ -62,10 +61,10 @@
<newPackagingParams/>
<modifiedPackagingParams/>
</airSettings>
<multiPlatformSettings enabled="true" hideAneLibSymbols="0" includePlatformLibs="false" platformID="com.adobe.flexide.multiplatform.ios.platform" reducedSizePackaging="false" version="1"/>
<actionScriptSettings version="1"/>
</buildTarget>
<buildTarget airDownloadURL="https://market.android.com/details?id=com.adobe.air" androidSettingsVersion="2" buildTargetName="device" isCurrent="true" platformId="com.adobe.flexide.multiplatform.android.platform">
<multiPlatformSettings enabled="true" hideAneLibSymbols="0" includePlatformLibs="false" platformID="com.adobe.flexide.multiplatform.android.platform" reducedSizePackaging="false" version="1"/>
<airSettings airCertificatePath="Certificate/haog.p12" airTimestamp="true" anePathSet="true" version="1">
<airExcludes/>
<anePaths/>
Expand All @@ -74,10 +73,10 @@
<newPackagingParams/>
<modifiedPackagingParams/>
</airSettings>
<multiPlatformSettings enabled="true" hideAneLibSymbols="0" includePlatformLibs="false" platformID="com.adobe.flexide.multiplatform.android.platform" reducedSizePackaging="false" version="1"/>
<actionScriptSettings version="1"/>
</buildTarget>
<buildTarget buildTargetName="default" isCurrent="true" platformId="default">
<multiPlatformSettings enabled="false" hideAneLibSymbols="0" includePlatformLibs="false" platformID="default" reducedSizePackaging="false" version="1"/>
<airSettings airCertificatePath="" airTimestamp="true" anePathSet="false" version="1">
<airExcludes/>
<anePaths/>
Expand All @@ -86,6 +85,7 @@
<newPackagingParams/>
<modifiedPackagingParams/>
</airSettings>
<multiPlatformSettings enabled="false" hideAneLibSymbols="0" includePlatformLibs="false" platformID="default" reducedSizePackaging="false" version="1"/>
<actionScriptSettings version="1"/>
</buildTarget>
</buildTargets>
Expand Down
10 changes: 10 additions & 0 deletions TeamX_Moblie/src/asset/Config/Constants.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2013 (http://www.altova.com) by () -->
<Root>
<!--场景默认缩放的最大倍率-->
<SCENE_ZOOM_MAX>1.5</SCENE_ZOOM_MAX>
<!--场景夜晚遮罩颜色-->
<SCENE_MASK_COLOR>0x0b0c18</SCENE_MASK_COLOR>
<!--场景夜晚遮罩的透明度-->
<SCENE_MASK_APHLA>0.55</SCENE_MASK_APHLA>
</Root>
9 changes: 3 additions & 6 deletions TeamX_Moblie/src/asset/Config/sceneConfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
<!-- edited with XMLSpy v2013 (http://www.altova.com) by () -->
<!-- 被2011 rel. 2 sp1 (haog) 使用XMLSpy vmf编辑的 (http://www.altova.com) by -->
<Root>
<scene sceneId="1" mapWidth="4096" mapHeight="2560" tileWidth="512" tileHeight="512" widthNum="8" heightNum="5" roadmap="/tiles/1/roadmap.png" atfFormat="/tiles/1/{0}.atf" initState="1" initAreoX="500" initAreoY="500" initAreoWidth="1024" initAreoHeight="768">
<!--state标识出现的场景类型 1为白天 2为晚上 4为下雪之类。。。。如果白天和晚上用同一个则是1+2 = 3-->
<buliders name="house_day" path="/tiles/1/house_day.atf" PosX="430" PosY="0" State="1"/>
<buliders name="house_night" path="/tiles/1/house_nolight.atf" PosX="430" PosY="0" State="2"/>
<lights name="light" path="/tiles/1/light.atf" PosX="430" PosY="0" State="2"/>
</scene>
<!--场景ID 场景的配置路径 场景类型 暂定0为普通场景-->
<scene sceneId="1" scenePath="scene/1/scene.xml" sceneType="0"/>
<scene sceneId="2" scenePath="scene/2/scene.xml" sceneType="0"/>
</Root>
11 changes: 11 additions & 0 deletions TeamX_Moblie/src/asset/initData.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2013 (http://www.altova.com) by () -->
<data>
<LoaderMax name="queue1" prependURLs="asset/" load="true">
<XMLLoader url="Config/Constants.xml" name="Constants" load="true"/>
<XMLLoader url="Config/sceneConfig.xml" name="sceneConfig" load="true"/>
<!--<SWFLoader url="swf/child.swf" name="child" autoPlay="false"/>
<VideoLoader url="video/video.flv" name="video" width="400" height="300" scaleMode="stretch" autoPlay="false"/>
<ImageLoader url="1.jpg" name="image1" load="true"/>-->
</LoaderMax>
</data>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
11 changes: 11 additions & 0 deletions TeamX_Moblie/src/asset/scene/1/scene.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2013 (http://www.altova.com) by () -->
<!-- 被2011 rel. 2 sp1 (haog) 使用XMLSpy vmf编辑的 (http://www.altova.com) by -->
<Root>
<scene sceneId="1" mapWidth="4096" mapHeight="2560" tileWidth="512" tileHeight="512" widthNum="8" heightNum="5" roadmap="/scene/1/roadmap.png" atfFormat="/scene/1/{0}.atf" initState="1" initAreoX="500" initAreoY="500" initAreoWidth="1024" initAreoHeight="768">
<!--state标识出现的场景类型 1为白天 2为晚上 4为下雪之类。。。。如果白天和晚上用同一个则是1+2 = 3-->
<buliders name="house_day" path="/scene/1/house_day.atf" PosX="430" PosY="0" State="1"/>
<buliders name="house_night" path="/scene/1/house_nolight.atf" PosX="430" PosY="0" State="2"/>
<lights name="light" path="/scene/1/light.atf" PosX="430" PosY="0" State="2"/>
</scene>
</Root>
1 change: 1 addition & 0 deletions XLib/.actionScriptProperties
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
</excludedEntries>
</libraryPathEntry>
<libraryPathEntry kind="3" linkType="1" path="/XEngine/bin/XEngine.swc" useDefaultLinkType="false"/>
<libraryPathEntry kind="1" linkType="1" path="lib"/>
</libraryPath>
<sourceAttachmentPath/>
</compiler>
Expand Down
3 changes: 2 additions & 1 deletion XLib/src/Test/ParticleTest.as
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ package Test
var ba:ByteArray = OpenFile.open(new File(Constants.resRoot + "/testRes/media/drugs.pex"));
var xml:XML = new XML(ba);


ba = OpenFile.open(new File(Constants.resRoot + "/testRes/media/drugs.png"));
// var particle:ParticleSystem = new ParticleSystem(xml,ba);

// Singleton.assets.loadQueue(onProgress);
// function onProgress(r:Number):void
Expand Down
16 changes: 9 additions & 7 deletions XLib/src/com/Game/Globel/Constants.as
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ package com.Game.Globel
import com.Game.GameScreen.PhotoTestScreen;
import com.Game.GameScreen.SceneStateTest;
import com.Game.GameScreen.WelcomeScreen;
import com.core.Common.ScreenManager;
import com.core.Common.Singleton;

import flash.filesystem.File;

import feathers.controls.ScreenNavigatorItem;

import starling.errors.AbstractClassError;
import com.core.Common.ScreenManager;
import com.core.Common.Singleton;

public class Constants
{
Expand Down Expand Up @@ -56,7 +56,7 @@ package com.Game.Globel
/**初始化常量配置*/
public static function init():void
{
loadConfig();
// readXml();

ScreenManager.screenNavigator;
ScreenManager.addScreen(SCREEN_WELCOME,new ScreenNavigatorItem(WelcomeScreen));
Expand All @@ -66,9 +66,11 @@ package com.Game.Globel
}

/**加载全局配置表*/
public static function loadConfig():void
public static function readXml(xml:XML):void
{
// 加载全局配置xml
SCENE_ZOOM_MAX = xml.SCENE_ZOOM_MAX;
SCENE_MASK_COLOR = xml.SCENE_MASK_COLOR;
SCENE_MASK_APHLA = xml.SCENE_MASK_APHLA;
}

/***********************静态常量配置 UISCREEN屏幕*****************/
Expand All @@ -86,8 +88,8 @@ package com.Game.Globel


/***********************静态常量配置 信号事件*****************/
public static const SIGNAL_STARLING_INIT:String = "StarlingInit";

public static const SIGNAL_STARLING_INIT:String = "StarlingInit";// starling 初始化完毕
public static const SIGNAL_SCENE_CREATE_COMPLETE:String = "SceneCreateCompele";// 创建场景完毕

/***********************场景的状态*****************/
public static const SCENE_STATE_DAY:int = 1; // 白天
Expand Down
45 changes: 35 additions & 10 deletions XLib/src/com/core/Basic/XGame.as
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ package com.core.Basic
{
import com.Game.Globel.Constants;
import com.core.Common.SceneManager;
import com.core.Common.ScreenManager;
import com.core.Common.Singleton;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.ImageLoader;
import com.greensock.loading.LoaderMax;
import com.greensock.loading.SWFLoader;
import com.greensock.loading.VideoLoader;
import com.greensock.loading.XMLLoader;

import feathers.themes.MetalWorksMobileTheme;
import flash.system.System;

import starling.display.Sprite;
import starling.events.Event;
import starling.events.Event;

public class XGame extends Sprite
{
// /**主舞台*/
protected var xStage:XStage;
protected var xmlLoader:XMLLoader;

public function XGame()
{
Expand All @@ -28,18 +33,38 @@ package com.core.Basic

private function init():void
{
// 初始化常量数据
Constants.init();
// 始化屏幕管理
ScreenManager.init();
// 初始化场景数据
SceneManager.init();
LoaderMax.activate([ImageLoader, SWFLoader, VideoLoader,XMLLoader]);
xmlLoader = new XMLLoader(Constants.resRoot + "/initData.xml", { onComplete:completeHandler, estimatedBytes:50000,onProgress:progressHandler } );
xmlLoader.load();

// // 始化屏幕管理
// ScreenManager.init();

xStage =new XStage;
addChild(xStage);

}

private function progressHandler(event:LoaderEvent):void
{
trace("progress:" + event.target.progress);
}

private function completeHandler(event:LoaderEvent):void
{
// 加载初始化配置表
var loader:XMLLoader = LoaderMax.getLoader("Constants");
Constants.readXml(loader.content);
System.disposeXML(loader.content);
// 加载场景列表
loader = LoaderMax.getLoader("sceneConfig");
SceneManager.readXml(loader.content);
System.disposeXML(loader.content);

// 加载配置完成之后释放所有资源
xmlLoader.dispose();
}


}
}
27 changes: 13 additions & 14 deletions XLib/src/com/core/Basic/XGameObject.as
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
package com.core.Basic
{
import com.Game.Globel.Constants;
import com.core.Controler.BaseControler;
import com.core.Math.QTree;
import com.core.Objects.Direction;
Expand Down Expand Up @@ -240,19 +239,19 @@ package com.core.Basic
var maxX:uint = XWorld.instance.scene.sceneData.mapWidth;
var maxY:uint = XWorld.instance.scene.sceneData.mapHeight;

if(XWorld.instance.camera.focusObject==this)
{
targetx = pos.x<(Constants.STAGE_WIDTH>>1) ? pos.x : (Constants.STAGE_WIDTH>>1);
targety = pos.y<(Constants.STAGE_HEIGHT>>1) ? pos.y : (Constants.STAGE_HEIGHT>>1);

targetx = pos.x>maxX-(Constants.STAGE_WIDTH>>1) ? pos.x-(maxX-Constants.STAGE_WIDTH) : targetx;
targety = pos.y>maxY-(Constants.STAGE_HEIGHT>>1) ? pos.y-(maxY-Constants.STAGE_HEIGHT) : targety;
}else{
// var target:Point = XWorld.instance.scene.tileMap.getScreenPostion(pos.x,pos.y);
// WorldMap.me.getScreenPostion(pos.x,pos.y);
// targetx = target.x;
// targety = target.y;
}
// if(XWorld.instance.camera.focusObject==this)
// {
// targetx = pos.x<(Constants.STAGE_WIDTH>>1) ? pos.x : (Constants.STAGE_WIDTH>>1);
// targety = pos.y<(Constants.STAGE_HEIGHT>>1) ? pos.y : (Constants.STAGE_HEIGHT>>1);
//
// targetx = pos.x>maxX-(Constants.STAGE_WIDTH>>1) ? pos.x-(maxX-Constants.STAGE_WIDTH) : targetx;
// targety = pos.y>maxY-(Constants.STAGE_HEIGHT>>1) ? pos.y-(maxY-Constants.STAGE_HEIGHT) : targety;
// }else{
//// var target:Point = XWorld.instance.scene.tileMap.getScreenPostion(pos.x,pos.y);
//// WorldMap.me.getScreenPostion(pos.x,pos.y);
//// targetx = target.x;
//// targety = target.y;
// }
x = Number(targetx.toFixed(1));
y = Number(targety.toFixed(1));
}
Expand Down
28 changes: 14 additions & 14 deletions XLib/src/com/core/Basic/XMap.as
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.core.Basic
{
import com.core.Astar.SilzAstar;
import com.Game.Globel.Constants;
import com.core.Common.DataStruct.SceneDataStruct;
import com.core.Common.DataStruct.SceneDataVO;
import com.core.Math.FastRectangleTools;
import com.core.Utils.File.OpenFile;

Expand All @@ -27,7 +27,7 @@ package com.core.Basic
public static var LIB_DIR:String = '/asset/';

/**tile 的高*/
public var _sds:SceneDataStruct;
public var _sds:SceneDataVO;

//////////////////////////////////////////////////////////////////////////
/** * 显示区域X数量*/
Expand Down Expand Up @@ -56,7 +56,7 @@ package com.core.Basic
private var _roadMap:BitmapData;

//////////////////////////////////////////////////////////////////////////
public function XMap(sds:SceneDataStruct)
public function XMap(sds:SceneDataVO)
{
_sds = sds;
casheMap = {tiles:new Object()};
Expand Down Expand Up @@ -160,15 +160,15 @@ package com.core.Basic

public function draw():void
{
var cameraView:Rectangle = XWorld.instance.camera.cameraCutView;
var num:int = this.numChildren;
for(var i:int = 0; i < num; i++)
{
var img:Image = this.getChildAt(i) as Image;
if(img == null) continue;
var bDraw:Boolean = FastRectangleTools.intersects(cameraView,new Rectangle(img.x,img.y,img.width,img.height));
img.visible = bDraw;
}
// var cameraView:Rectangle = XWorld.instance.camera.cameraCutView;
// var num:int = this.numChildren;
// for(var i:int = 0; i < num; i++)
// {
// var img:Image = this.getChildAt(i) as Image;
// if(img == null) continue;
// var bDraw:Boolean = FastRectangleTools.intersects(cameraView,new Rectangle(img.x,img.y,img.width,img.height));
// img.visible = bDraw;
// }
}

public function reset():void
Expand Down Expand Up @@ -247,8 +247,8 @@ package com.core.Basic
/*** 根据世界坐标获取在屏幕内的坐标 */
public function getScreenPostion(x:Number,y:Number):Point
{
_turnResult.x = x - XWorld.instance.camera.zeroX;
_turnResult.y = y - XWorld.instance.camera.zeroY;
// _turnResult.x = x - XWorld.instance.camera.zeroX;
// _turnResult.y = y - XWorld.instance.camera.zeroY;
return _turnResult;
}

Expand Down
Loading

0 comments on commit bd5adc0

Please sign in to comment.