OGeek|极客世界-中国程序员成长平台

标题: ios - CCsprite move后如何实现CCMotionStreak? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 17:08
标题: ios - CCsprite move后如何实现CCMotionStreak?

你好 friend ,我想在 Sprite 从一个点移动到另一个点后实现 MotionStreak。当它移动时,它的显示阴影 (MotionStreak)。我该如何实现它。

enter image description here



Best Answer-推荐答案


首先你在 init 方法中获取一个 Sprite ,它在屏幕上移动

torpedoOne = [CCSprite spriteWithFile"Button1.png"];
        torpedoOne.position = ccp(0,0);
        [self addChild:torpedoOne z:2];

现在在 init 方法中使用 CCMotionStreak

 streak = [CCMotionStreak streakWithFade:1.7f minSeg:5 width:10 color:ccWHITE textureFilename"Button1.png"];
    streak.position =torpedoOne.position;
[self addChild:streak z:2];

SpriteMove 的 Action

   id actionMove = [CCMoveTo actionWithDuration:2.0
                                        position:ccp(320, 320)];
    [torpedoOne runAction:[CCSequence actions:actionMove, nil]];

更新 Sprite 位置

[self scheduleselector(doStep];

更新方法

- (void)doStepccTime)delta
{
    //update the position
    [streak setPosition:torpedoOne.position];
}

关于ios - CCsprite move后如何实现CCMotionStreak?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20511341/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4