egret on-line client 1 press the rocker and client 2 update the corresponding role position, remove the rocker and stop

Keywords: JSON

Here's Client 2 Moving Role after Client 1 Presses the Rocker
p2 does not move until p1 moves the rocker
Set judgment move var zou=false
zou=true when touching the rocker;
Pass zou to server and zou to p2

 function chuans(){
  var cmd = {
       // "y":sky.y,
  let Msg:string = JSON.stringify(cmd);
 // var cmd6 = 64;
        console.log("Connect successfully, send data:" + Msg);

Store the value returned by the server in the class

function onReceiveMessage(e: egret.Event): void {
        var msg = this.webSocket.readUTF();
        var cx=eval('('+msg+')');,cx.y,cx.zou);
        console.log("Data received:" + cx.fff+ang.jieguo+".......................................");

Class dx

class dx{
    public chuanx=null;
    public chuany=null;
    public x=null;
    public y=null;
    public chuanzou=null;
    public zouu=null;
  //  public shpwaix=null;
   // public neiy=null;
   // public shpwaiy=null;

    public run(chuanx,chuany,chuanzou){

In timmer, which controls p1 client to display p2 role movement, it is judged that if the returned zou is true to prove that another client is touching the rocker, then the position of role sky6 is updated in this client.

function cont6246(){
  if(dxx.zouu==true){//If the zou returned from the other client is true, the other client touches the rocker and returns true.

  // var request = new egret.HttpRequest();
  //  var zou="?x="+sky.x+"&y="+sky.y+"";
//request.responseType = egret.HttpResponseType.TEXT;
if(tingbeijing==true){//If false means that the map will not move beyond the boundary
         group.x=group.x-Math.cos(dxx.x)*2; //Longitudinal rolling position
 group.y  =group.y-Math.sin(dxx.x)*2//group is the map container sprite



Posted by nsr500rossi on Thu, 03 Oct 2019 21:57:07 -0700