0

我试图为标签生成一个动作,这是一个精灵的属性。

这就是我正在尝试的,但标签没有移动,我无法确定它们不移动的原因。

    - (void) spriteLabelMoveFinished:(id)sender
    {
CCLOG(@"AnimateLabel Move Finished");
Sprites *sprite = (Sprites *)sender;

CCLOG(@"LabelFinalPosition: %f,%f",sprite.spriteLabel.position.x,sprite.spriteLabel.position.y);
[self animateSpriteLabel:sprite.spriteLabel];

    }


    -(void)animateSpriteLabel:(Sprites *)sprite
    {
CCLOG(@"We're animating the SpriteLabel");

CCLabelTTF *spriteLabel = nil;

spriteLabel = sprite.spriteLabel;


int actualDuration = spriteLabelSpeed; // Another Property, inside the .m

// Create the actions

CCLOG(@"AnimatingLabel LabelPosition: %f,%f",spriteLabel.position.x,spriteLabel.position.y);

id actionMove = [CCMoveBy actionWithDuration:actualDuration
                                    position:ccpMult(ccpNormalize(ccpSub(_player.position,spriteLabel.position)), 10)];

id actionMoveDone = [CCCallFuncN actionWithTarget:self
                                         selector:@selector(spriteLabelMoveFinished:)];
[sprite runAction:
 [CCSequence actions:actionMove, actionMoveDone, nil]];

    }

标签只是出现并没有移动....感谢您的帮助和时间,祝您好运!

4

2 回答 2

0

该行:

[self animateSpriteLabel:sprite.spriteLabel];

应该读:

[self animateSpriteLabel:sprite];

我认为这会产生你想要的结果。我有点惊讶你没有编译器警告/错误。

于 2013-06-12T06:36:58.807 回答
0

您正在对 Sprite 对象而不是 spriteLabel 运行操作。尝试改变:

[sprite runAction:
    [CCSequence actions:actionMove, actionMoveDone, nil]];

[spriteLabel runAction:
    [CCSequence actions:actionMove, actionMoveDone, nil]];
于 2013-06-10T15:39:28.667 回答