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

大佬,求助。未知的错误

$
0
0

@2232776923 写道:

想要实现的效果是:
击中敌人之后,会有奖励掉落。
但是在自由落体开始前,给了一个随机速度。

                    //设置初始速度
                    let rigidBody = item.children[i].getComponent(cc.RigidBody);
                    let velocity = cc.v2(0, 0);
                    if (rigidBody) {
                        let xVelocityAry = [100, -100, 150, -150];
                        let aryIndex = Math.floor(Math.random() * 5);
                        let xVelocity = xVelocityAry[aryIndex];
                        velocity = cc.v2(xVelocity, 100);
                    }
                    rigidBody.linearVelocity = velocity;
                

                  item.parent = this.node.parent;
                  item.x = posX;
                  item.y = posY;

在设置item.x 的位置就报错了(偶现bug)。
报错如下:

帖子: 1

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88848

Trending Articles



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