gpt4 book ai didi

ios - Cocos2d,使用大于和小于整数值的限制来显示 Sprite

转载 作者:行者123 更新时间:2023-11-29 03:07:06 24 4
gpt4 key购买 nike

我正在使用 cocos2d 创建一个 DNA 主题的 Flappy Bird 风格的游戏(长话短说,不要指望从中赚到钱)。我正在尝试创建一个系统,根据某一轮达到的分数奖励“奖牌”。我正在使用大于和小于方法来指示是否应该接收某个“奖章”。但是,我的所有奖牌同时出现,而不是根据分数单独显示。这是适用的代码:

NSInteger _points;

-(BOOL)ccPhysicsCollisionBegin:(CCPhysicsCollisionPair *)pair hero:(CCNode *)hero goal:(CCNode *)goal {
[goal removeFromParent];
_points++;
_scoreLabel.string = [NSString stringWithFormat:@"%d", _points];
[self saveState];
[self loadSavedState];
if (_points > _highScore) {
_highScore = _points;
}
return TRUE;
}

- (void)gameOver {
if (!_gameOver) {
_scrollSpeed = 0.f;
_gameOver = TRUE;
_restartButton.visible = TRUE;
_menuButton.visible = TRUE;
_gameOverText.visible = TRUE;
_score.visible = TRUE;
_highScoreValue.visible = TRUE;
_highScoreLabel.visible = TRUE;
_medal.visible = TRUE;
if (9 < _points < 20) {
_uracil.visible = TRUE;
_uracilLabel.visible = TRUE;
}
if (19 < _points < 30) {
_thymine.visible = TRUE;
_thymineLabel.visible = TRUE;
}
if (29 < _points < 40) {
_cytosine.visible = TRUE;
_cytosineLabel.visible = TRUE;
}
if (39 < _points < 50) {
_guanine.visible = TRUE;
_guanineLabel.visible = TRUE;
}
if (49 < _points < 60) {
_adenine.visible = TRUE;
_adenineLabel.visible = TRUE;
}
_scoreLabel.position = ccp(260, 358);
_hero.physicsBody.allowsRotation = FALSE;
[_hero stopAllActions];
CCActionMoveBy *moveBy = [CCActionMoveBy actionWithDuration:0.2f position:ccp(-5, 5)];
CCActionInterval *reverseMovement = [moveBy reverse];
CCActionSequence *shakeSequence = [CCActionSequence actionWithArray:@[moveBy, reverseMovement]];
CCActionEaseBounce *bounce = [CCActionEaseBounce actionWithAction:shakeSequence];
[self runAction:bounce];
}
}

我怎样才能让“奖牌”在应该基于分数的时候出现?感谢您的帮助。

最佳答案

替换这些

if (9 < _points < 20)

if (_points > 9 && _points < 20)

关于ios - Cocos2d,使用大于和小于整数值的限制来显示 Sprite ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22646816/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com