【问题标题】:Sprite Sheet Animation while moving it to another place将精灵表动画移动到另一个地方
【发布时间】:2014-11-09 07:09:42
【问题描述】:

我正在尝试使精灵表动画与另一个动作一起使用。为此,我有一个没有任何 .plist 文件的 Sprite 表 .png 文件。我的问题是 spritesheet 动画可以工作,但是在下面的代码块中使用像这样的其他操作却不能。它会首先将其移动到目的地,然后对其进行动画处理,但我希望它在动画自身的同时移动。

void animatespritesheet()
{
     for(i=0;i<10;i++)
         {

            _spriteFrame=CCSpriteFrame::create("bulb_f.png",CCRectMake(i*75,0,75,75));

            _anims->addObject(_spriteFrame);
         }

    _animation=CCAnimation::createWithSpriteFrames(_anims,1.0f);

    CCSprite* sprite = CCSprite::createWithSpriteFrame(_spriteFrame);
    //sprite->setPosition(ccp(256,256));

    CCAction* axn = CCRepeatForever::create(CCAnimate::create(_animation));
    /*CCAction *axn1 = CCMoveTo::create(1.0f,CCPoint(200,200));
    CCMoveTo* move = CCMoveTo::create(1.0f,CCPoint(200.0,200.0));*/
    _spriteBatch->addChild(sprite);
    sprite->runAction(axn);
    //sprite->runAction(move);
    //sprite->runAction(CCSequence::Create(move,axn,NULL);
   }

_anims 是一个 CCArray。 png 文件是 75*750 文件,包含 10 帧。 我一个人做不了这件事。请帮我解决这个问题。我真的需要帮助。

【问题讨论】:

    标签: animation cocos2d-x sprite sprite-sheet


    【解决方案1】:

    使用 CCSpawn 同时运行两个操作(本示例假设 cocos 3.0)。

    [CCActionSpawn actions:action1, action2, nil];
    

    【讨论】:

    • Allen,严格来说,在这种情况下,OP 只能在同一个对象上运行两个动画。当您需要在飞行中按顺序分叉两条路径时,CCActionSpawn 是强制性的……如果我没记错的话。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多