使 text = int (cocos2d iPhone)
我有一个名为percentComplete 的int(用于SplashScene)。我需要将其制作成文本(CCLabelBMFont),其数字与 int 相同,并在 int 时更新。想象一个加载屏幕,其中有一个数字表示距离游戏开始还有多远(77%)。到目前为止我已经开始了。我最终收到了警告。 %Complete 是 int,percentCompleteText 是 CCLabelBMFont
-(void)displayPercentCompleteText:(id)sender {
percentCompleteText = (CCLabelBMFont *) [self getChildByTag:kTagPercentComplete];
[percentCompleteText setString:[percentComplete getPercentCompleteAsString]]; //Invalid receiver type 'int'
percentCompleteText.position = ccp(111, 111); //CHANGE POSITION
//SCHEDULE UPDATE EVERY .01s
}
-(NSString *)getPercentCompleteAsString {
return [NSString stringWithFormat:@"%d", percentComplete];
}
I have an int named percentComplete (for a SplashScene). I need to make that into text (CCLabelBMFont) that will have the same number as the int, and be updated when the int is. Think of a loading screen that has a number represent how far it is until the game can start (77%). I've started with this so far. I end up with a warning. percentComplete is the int, percentCompleteText is a CCLabelBMFont
-(void)displayPercentCompleteText:(id)sender {
percentCompleteText = (CCLabelBMFont *) [self getChildByTag:kTagPercentComplete];
[percentCompleteText setString:[percentComplete getPercentCompleteAsString]]; //Invalid receiver type 'int'
percentCompleteText.position = ccp(111, 111); //CHANGE POSITION
//SCHEDULE UPDATE EVERY .01s
}
-(NSString *)getPercentCompleteAsString {
return [NSString stringWithFormat:@"%d", percentComplete];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设
-(NSString *)getPercentCompleteAsString
与-(void)displayPercentCompleteText:(id)sender
属于同一类,而percentComplete
是该类的成员变量 (ivar) ..将行:更改
为:
I'm assuming
-(NSString *)getPercentCompleteAsString
is in the same class as-(void)displayPercentCompleteText:(id)sender
andpercentComplete
is a member variable (ivar) of that class ..Change the line:
to:
如果您将行更改为
而不是 double 会怎么样..
what if you change the line to
instead of double..