用Flash+Java构建网游?思索中...

    技术2022-05-11  104

    最近看到一位高手做的Flash坦克大战局域网游, 觉得实在是强人!自己也在思索开发一款Flash网游.没想到已经有高手的范例了,激动不已!

    下面把该高人的源程序给大家分享!

    服务器端文件列表:

    CommServer.java

    CSClient.java

    CommServer.class

    CSClient.class

    .classpath

    .project

    客户端文件列表:

    坦克大战.fla

    坦克大战.swf

    /

    /

    //

    源代码列表:

    // /CommServer.java import  java.awt.event. * ; import  java.util. * ; import  java.awt. * ; import  java.io. * ; import  java.net. * ; /** * * CommServer * <BR><BR> * Generic Flash Communication Server.  All communications sent and received * are (must be) terminated with a null character ('

     

    ///CSClient.java import java.awt. event . * ;import java.util. * ;import java.awt. * ;import java.io. * ;import java.net. * ; /** * * CommServer * <BR><BR> * Generic Flash Communication Server.  All communications sent and received * are (must be) terminated with a null character ('

     

     

    ////坦克大战.fla-------Start_btn----AS2.0 on (release)  {    //声明XMLSocket对象//连接服务器//IPText.text是舞台上一个输入主机IP的输入文本!!!//PORTText.text是舞台上一个输入主机端口的输入文本!!!mySocket.connect(IPText.text,Number(PORTText.text));//mySocket.onXML=function(xmlDoc){//如果返回的是编号信息    if(xmlDoc.firstChild.nodeName=="NUMCLIENTS")    {        //trace(xmlDoc.firstChild.nodeName="NUMCLIENTS");        trace(xmlDoc.firstChild.firstChild.nodeValue);                if(serIDtemp==-1)        {            serIDtemp=xmlDoc.firstChild.firstChild.nodeValue;                    }        if(xmlDoc.firstChild.firstChild.nodeValue==enemys)        {            createPlayer();            gotoAndPlay ("StartPlay");            }        //for(i=0;i<enemys;i++)          //if has more than 2 players we will use this method        //{}        //I will use follow simple method to give the "playersNum" value        /*        if(serIDtemp!=-1)        {        _root.PTank0.playersNum=xmlDoc.firstChild.firstChild.nodeValue;        _root.PTank1.playersNum=xmlDoc.firstChild.firstChild.nodeValue;        trace("plyayersNum");        trace(_root.PTank1.playersNum);        }*/        trace(serIDtemp);        //trace(_root.PTank0.serID);        // gotoAndStop(2);        // _root.myName="ship"+xmlDoc.firstChild.firstChild.nodeValue;        // mySocket.onXML=playGame;    }//trace(_root.PTank0.serID);//如果返回的是人满的信息   // if(xmlDoc.firstChild.nodeName="err"){       // gotoAndStop(3);     //   mySocket.close();    //}}///mySocket.onConnect=function(success){    if(success){        trace("连接成功");        connState.text="连接成功,wait>";        stop();                        //bBtn.enabled=true;    }else{        trace("连接失败");        connState.text="连接失败";        //bBtn.enabled=false;    }}//////    }

     

     

     

     

     

     

     


    最新回复(0)