Hi Folks,
Goal:
I am trying to move my sprite(man) to the right continuously while its sprite’s frames is changing. Changing as in loop.
Actual(Current):
The scenario is that the sprite moves to the right but its frames changes at interval. So its effect seems that the man moves but his feet is only moving at some time.
Here is my code so far:
spritecache->addSpriteFramesWithFile("walkRight.plist");
characterSpriteBatchNode=SpriteBatchNode::create("walkRight.png");
characterSpriteBatchNode->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
this->addChild(characterSpriteBatchNode);
characterSprite=Sprite::createWithSpriteFrameName("right1.png");
animation=Animation::create();
for(int i=1;i<=4;i++)
{
char szName[100]={0};
sprintf(szName,"right%d.png",i);
animation->addSpriteFrame(SpriteFrameCache::getInstance()->spriteFrameByName(szName));
}
animation->setDelayPerUnit(5.0f);
characterSprite->runAction( RepeatForever::create( Spawn::create(Animate::create(animation), MoveBy::create(MOVESPEED, Vec2(MOVE_BY, 0)), nullptr)));
characterSpriteBatchNode->addChild(characterSprite);
Thanks.