本文整理汇总了C++中CCAnimate::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ CCAnimate::copy方法的具体用法?C++ CCAnimate::copy怎么用?C++ CCAnimate::copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCAnimate
的用法示例。
在下文中一共展示了CCAnimate::copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: spriteWithFile
Player* Player::spriteWithFile(const char *pszFileName, int columns, int rows)
{
// CCSpriteFrame *frame = cacher->spriteFrameByName( pszFileName);
CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage(pszFileName);
CCArray* aFrames = CCArray::createWithCapacity(columns * rows);
float textureWidth = texture->getPixelsWide();
float textureHeight = texture->getPixelsHigh();
float frameWidth = textureWidth / columns;
float frameHeight = textureHeight / rows;
for (int c = 0; c < columns; c++)
{
for (int r = 0; r < rows; r++)
{
CCSpriteFrame *frame0 = CCSpriteFrame::createWithTexture(texture, CCRectMake((c*frameWidth), (r*frameHeight), 100, 65));
aFrames->addObject(frame0);
}
}
CCAnimation *animation = CCAnimation::createWithSpriteFrames(aFrames, 0.2f);
CCAnimate *animate = CCAnimate::create(animation);
CCActionInterval* seq = (CCActionInterval*)(CCSequence::create( animate, animate->copy()->autorelease(), CCFlipX::create(false), NULL) );
Player *pobSprite = new Player();
if (pobSprite && pobSprite->initWithSpriteFrame((CCSpriteFrame*) aFrames->objectAtIndex(0)))
{
pobSprite->scheduleUpdate();
pobSprite->autorelease();
pobSprite->setForwardMarch(false);
pobSprite->setMightAsWellJump(false);
pobSprite->setBackwardMarch(false);
pobSprite->runAction(CCRepeatForever::create( seq ) );
// pobSprite->setAnimFrames( aFrames);
// pobSprite->setCurrentFrame(0);
return pobSprite;
}
CC_SAFE_DELETE(pobSprite);
return NULL;
}