【发布时间】:2013-12-26 19:27:39
【问题描述】:
以下代码出现预期表达式错误:
(void) for(t; t < kPlatformsStartTag + kNumPlatforms; t++) { //error here
CCSprite *platform = (CCSprite*)[batchNode getChildByTag:t];
CGSize platform_size = platform.contentSize;
CGPoint platform_pos = platform.position;
max_x = platform_pos.x - platform_size.width/2 - 10;
min_x = platform_pos.x + platform_size.width/2 + 10;
float min_y = platform_pos.y + (platform_size.height+bird_size.height)/2 - kPlatformTopPadding;
if(bird_pos.x > max_x &&
bird_pos.x < min_x &&
bird_pos.y > platform_pos.y &&
bird_pos.y < min_y) {
[self jump];
}
}
(void) for(t; t < kCloudsStartTag + kNumClouds; t++) { //error here
CCSprite *cloud = (CCSprite*)[batchNode getChildByTag:t];
CGPoint pos = cloud.position;
pos.y -= delta * cloud.scaleY * 0.8f;
if(pos.y < -cloud.contentSize.height/2) {
currentCloudTag = t;
[self resetCloud];
} else {
cloud.position = pos;
}
}
错误出现在“for”代码所在的位置。我将(无效)代码放入,因为我会得到一个表达式结果未使用的错误。有什么想法吗?
【问题讨论】:
-
生成的错误究竟是什么?以及在
for之前没有void的错误? -
这与 Xcode 无关。
-
另外,学习 C 的基础知识(可能使用书籍或教程)。您必须了解该语言的基本要素,我们不是来用勺子喂给您的。
-
@H2CO3 - 感谢您的建议,但对我的问题没有帮助。我在 xcode 引擎上使用 Objective-C。
-
@rullof - 我得到的没有 void 的错误是未使用的实体问题 - 表达式结果未使用。我从这个页面得到了 void 解决方案:stackoverflow.com/questions/7914990/…
标签: objective-c compiler-errors