Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88737

求教,这段代码是什么意思?

$
0
0

@758482981 写道:

请问下 为啥初始化时用 var xIndex = arguments[1][0]//???? var count = arguments[1][1]//?????
还有 this.node.runAction(action) 里面的action 是不是数组动作,是不是几个动作变成数组,也可以node.runAction([])

var actionAry = [] //建立一个动作数组 ???
var self = this // 用于闭包
//消除
var count = 0 //初始化,下面遍历需要
for (var i = 0; i < xcList.length; i++) {//遍历二维数组中一个方向
var oneList = xcList[i] //赋值
for (var j = 0; j < oneList.length; j++) { //遍历二维数组中另一个方向
var xIndex = oneList[j] //赋值
//将粒子特效加入
actionAry.push(cc.callFunc(function(){
var xIndex = arguments[1][0]//????
var count = arguments[1][1]//?????
var effNode = cc.instantiate(this.boomEffPrefab)
this.frameList[xIndex].addChild(effNode)

                //加分飘字
                var tipNode = cc.instantiate(this.tipPrefab)
                var label = tipNode.getComponent(cc.Label)
                label.string = "+" + this.getAddScoreCal(count)
                this.frameList[xIndex].addChild(tipNode)
            }, this, [xIndex, count]))

            //方块的本身消除
            actionAry.push(cc.callFunc(function(){
                var xIndex = arguments[1]//?????
                this.frameList[xIndex].isHaveFK = null

                var FKNode = this.frameList[xIndex].getChildByName("colorSpr")
                if (!FKNode) {
                    return//防止没有这个方块的时候
                }
                //FKNode.removeFromParent()

               FKNode.cascadeOpacity = true
                //这个假方块变大并且渐隐掉
                FKNode.runAction(cc.sequence(
                    cc.spawn(cc.scaleTo(0.5, 2), cc.fadeOut(0.5)),
                    cc.removeSelf(true)
                ))
                
            }, this, xIndex))

            actionAry.push(cc.delayTime(0.1))

            count++
        }

}

    if (actionAry.length > 0) {
        actionAry.push(cc.callFunc(function(){
            this.isDeleting = false
            this.checkIsLose()
        }, this))

        this.isDeleting = true
        var action = cc.sequence(actionAry)
        this.node.runAction(action)

        //加分
        this.addScore(count)
    }

代码来源 https://github.com/WuBuzi/LBXGame

帖子: 1

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>