Sprite Animation using cocos2dx 2.0.2

Posted by Lalit Chattar on Game Development See other posts from Game Development or by Lalit Chattar
Published on 2012-09-11T06:37:51Z Indexed on 2012/09/11 9:51 UTC
Read the original article Hit count: 335

Filed under:
|

I am new in game development and learning coco2dx framework. I am trying to implement sprite animation using coco2dx. i tried many demo they all are same. But when i tried i got access violation error in my code.

CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("AnimBear.plist");
    CCSpriteBatchNode *spreetsheet = CCSpriteBatchNode::create("AnimBear.png");
    this->addChild(spreetsheet);

CCArray *bearArray = new CCArray();
     for(int i = 1; i <= 8; i++)
{
        char name[32] = {0};
         sprintf(name, "bear%d.png",i);
        bearArray->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name));
}
    CCAnimation *walkAnim = CCAnimation::animationWithSpriteFrames(bearArray, 0.1f);
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    CCSprite *bear = CCSprite::spriteWithSpriteFrameName("bear1.png");
    bear->setPosition(ccp(size.width/2, size.height/2));
    CCAction *walkAction = CCRepeatForever::actionWithAction(CCAnimate::actionWithAnimation(walkAnim));
    bear->runAction(walkAction);
spreetsheet->addChild(bear);

error is coming in first line while we passing plist refrence. Plese help me. I a using Visual Basic 2010 and put both files in Resource folder (png and plist).

© Game Development or respective owner

Related posts about c++

Related posts about cocos2d-x