コード例 #1
0
            else if (data.type == 'refuse') {
                cc.vv.alert.show('该玩家拒绝了你的邀请');
            }
            else if (data.type == 'cannel') {
                cc.vv.alert.show('邀请被取消');
            }
        }
        else{
            cc.vv.alert.show(obj.message);
        }
    },

    onLoad () {
        cc.director.setDisplayStats(false);

        let isHave = NetControl.connect();
        this.msssageFire=onfire.on("onmessage",this.onMessage.bind(this));

        if (isHave) {
            NetControl.send( 'getList', '', '');
        }
    },

    createInviteList: function (playerList,num) {
        const x = -250;
        let y = 540;

        for (var i = 0; i < playerList.length; i++) {
            let x2 = x + (i % 3 * 220);
            if (i % 4 == 0 && i != 0) {
                y -= 30; 
コード例 #2
0
            let y = touchLoc.y;

            x = x > 680 ? 680 : x;
            x = x < 70 ? 70 : x;

            y = y > 607 ? 607 : y;
            y = y < 70 ? 70 : y;

            this.player1Node.setPosition(x,y)
            NetControl.send( 'player', {x:x, y:y}, gameUser);
        }, this);
    },

    onLoad () {
        cc.director.setDisplayStats(false);
        NetControl.connect();

        this.setInputControl();
        if ( sessionStorage.getItem('first') == 1 ) {
            this.createBall(375,400);
        }
        else{
            this.createBall(375,934);
        }

        this.msssageFire=onfire.on( "onmessage", this.onMessage.bind(this) );
    },

    createBall: function (x, y) {
        // 使用给定的模板在场景中生成一个新节点
        var newBall = cc.instantiate(this.ballPrefab);