Click here to load reader

Flash mmorpg游戏引擎及工具开发概述-张明光

  • Upload
    flash

  • View
    3.893

  • Download
    0

Embed Size (px)

DESCRIPTION

 

Citation preview

  • 1. Flash-MMORPG
    (saiman)
    2010.7.1
    QQ:457691057
    Blog:http://wxsr.blogbus.com/

2. :
3. WEBGAME ()
1.
(),
,().
:
1.()
,
2.()
,
3.()

4.()

:
1.
2.
3.2
4. ----
1.
:(),
..

,().
,.
()
5. ---------
1.
,
6. ()----,
,
: IOrder,.
(,)
:
1. (Iorder)
2. .
:
1.
AS3
2.
public interface IOrder
{
function get execHandler():Function;
function get callbackHandler():Function;
function setUp(execHandler:Function,args:Array, callbackHandler:Function)
}
7. .
public interface IOrder
{
functionset id(value:int):void;
functionget id():int
function execHandler():Object;
function callbackHandler(args:Array):Object;
function setUp(execHandler:Function,args:Array, callbackHandler:Function);
}
as3
:
1.,
.
.
IEventDispatcher.
...
2.,,,2.,,.
,
8. .
AS3()
Target.addEventListener(EventType.EVENT_NAME,eventResponse)

,
:
.
:

,
:

,,,
:
1.
( null)
2.().
3.
9. :
:,.
:,.
:
DisplayObject.ENTER_FRAME:
:..()
.,.
Timer
:,.cpu.

setInterval
Timer.,Timer.
as2as2setInterval,,
.
setTimeout
,setInterval .
:timer.
timertimer.
,,,,.
,.
,
,
10. playerglobal.swc
SetIntervalTimer
package flash.utils
{
import flash.events.*;
final class SetIntervalTimer extends Timer
{
varid:uint;
private varrest:Array;
private varclosure:Function;
private static varintervals:Array = [];
function SetIntervalTimer(closure:Function, delay:Number, repeats:Boolean, rest:Array)
{
super(delay, repeats ? (0) : (1));
this.closure = closure;
this.rest = rest;
addEventListener(TimerEvent.TIMER, this.onTimer);
start();
this.id = intervals.length + 1;
intervals.push(this);
return;
}// end function
private function onTimer(event:Event) : void
{
this.closure.apply(null, this.rest);
if (repeatCount == 1)
{
if (intervals[(this.id - 1)] == this)
{
delete intervals[(this.id - 1)];
}
}
return;
}// end function
static function clearInterval(id_to_clear:uint) : void
{
id_to_clear = id_to_clear - 1;
if (intervals[id_to_clear] is )
{
intervals[id_to_clear].stop();
delete intervals[id_to_clear];
}
return;
}// end function
}
}
,
:


.
:
1.timer,timer.
2.timer,.
3.Timer,EnterFrame
4.,
11. -------

1.
12.


:
:
.
1.,
2.
3.
.:
,send,
:()


:(2)
1.
2.
3.

-----
Message=Head+Body
Message()Head(,,,)Body(,,Iorder)
13. MODULE

:
()
2,.

(ModuleToModule)
(ModuleToSevice)
(SubModule--)

-Moudle(MVC)
public interface IModule
{
function getview():IBaseSprite
function setview(value:IBaseSprite):void
function register(moduleName:String):void
function send(message:IMessage):void
functionget proxy():IProxy
}
14.

:

  • 9.:,,,,

15. 10.:,,,,, 16. 11. (,) 17. 12.(,) 18. 13. 19. 14. 20. 15. 21. 16. 22. 17. 23. 1. 24. 2.() 25. 3./, (,;) 26. 4. (bitmapdata) 27. 5.(,html,tree) 28. 6.(,,) 29. 7. (ui) 30. 8 (ui):
1.(,)
2.(,,)
3.(,
)
4.message

31. --------SubModule( )

mvc
,.

1.
2.,.
SubModule,..
,.SubModule, SubModule,SubModule().SubModule()..
32.
1.

33. WEBGAME :

34.

:IBaseSprite
1.,.
2.(IBaseVo),.
3..
.
1. webgame,.
2.catchAsBitmap
(,,MovieClipcatchcatch)
3.,cpu(,catchAsBitmap)
Ui
1.
2.Fl
AsWing,
FlexSpark
35.
--4
1..
2.
3.
4.ai
5..
cpu
1.mouseEnabledmouseChildren
2.addChild(),addChildAt()()
3.(,)
4.
:
Array.push() Array.pop()()
5.Alpha
6.publicseter()geter(),
7..
8.,()
36.

1.
37.
,,
,.
;
.
,..
38. :
Target





39. OTHER--
3.
2.
40. 41.
,,(3d)
,.
:
1.
2.
3.AI;
4.,A*

.
:
;
,
:
,
.

42.
:
rectWidth=Width/(4^(n-1))
rectHeight=Height /(4^(n-1))
::
W_1=10000
1
W_2=10000 / 4 = 2500 Sn=4
2
W_3=10000 / 4*4 = 10000 / 16 = 625 Sn=20
3
W_5=10000 / 4*4*4 = 10000 / 64 = 156.25Sn=84
4
W_6=10000 / 4*4*4*4 = 10000 / 256 = 39.0625sn=340
5
W_6=10000 / 1024 = 9.765625sn=1364
6
W_6=10000 / 4096 = 2.44140625Sn=6460
7
W_7=10000/16384=0.6103515625sn=21844

:(4^)
10000,6:
4+16+256+1024+4096=
(4-4096*4)/(1-4)=6460
:
:
:
43. 45
Function : getOnlyDepthFunctarget:DisplayObject,source:Array:Object
target --
source --target
itemDepth target residualSourcetarget

n sourceN:ArraygetOnlyDepthFunc
getOnlyDepthFunc target residualSourcesource residualSourcetarget itemDepth sourceN:Array
getOnlyDepthFuncsource
residualSourcesourceN
sourceNrebackSource rebackSource2itemDepth
residualSourceitemDepthundefiendresidualSourcetarget sourceN:Array
44. C-C
B-R
B-L
C-L
B-C
T-L
[B-L] [B-C] [B-R] [C-L]
[C-C]
[C-R] [T-L] [T-C] [T-R]

item.sideR=(target.[B].y-item.[L].y)
item.sideL=(item.[B].y-target.[L].y)
item.sideB=(target.[T].x-item.minZ.[L].x)
item.sideT=(item.[T].x-target.[L].x)
item.sideR