We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
因为Player.ts下的getCenterPos返回的是只有x和y的cc.v2
getCenterPos () { //var centerPos = cc.v2(this.node.x, this.node.y + this.node.height/2); //必须改成下面带有z坐标的v3,上面注释掉的v2不行 var centerPos = cc.v3(this.node.x, this.node.y + this.node.height/2, 0); return centerPos; }
从而导致如下Star.ts里getPlayerDistance 计算距离dist的结果为NaN了
getPlayerDistance () { // 根据 player 节点位置判断距离 var playerPos = this.game.player.getCenterPos(); // 根据两点位置计算两点之间距离 var dist = this.node.position.sub(playerPos).mag(); return dist; }
debug看了下是因为cc.Node的getPosition返回的是Vec3而不是Vec2,所以this.node.position.sub(playerPos).mag()结果就是NaN了
The text was updated successfully, but these errors were encountered:
No branches or pull requests
因为Player.ts下的getCenterPos返回的是只有x和y的cc.v2
从而导致如下Star.ts里getPlayerDistance 计算距离dist的结果为NaN了
debug看了下是因为cc.Node的getPosition返回的是Vec3而不是Vec2,所以this.node.position.sub(playerPos).mag()结果就是NaN了
The text was updated successfully, but these errors were encountered: