Sergey Shambir wrote:
Use void LoadingLayer::foo(cocos2d::CCObject *object)
and cast object with CCTexture2D *tex = static_cast<cocos2d::CCTexture2D *>(object);
Answer about thanks!
after i debug.
i face to another problem…
i write to LoadingLayerScene.cpp
void LoadingLayer::spritesLoaded(CCObject * object)
{
CCTexture2D * tex = static_castcocos2d::CCTexture2D*(object);
}
and
debug error: cocos2d: CCSpriteFrameCache: Trying to use file sprites.png as texture
i input code of all…
you confirm my code… waiting for answer…
have a good time…
bool LoadingLayer::init()
{
bool bRet = false;
do
{
CC_BREAK_IF(! CCLayer::init());
isLoading = true;
imagesLoaded = false;
this~~>setTouchEnabled;
winSize = CCDirector::sharedDirector~~>getWinSize;
defaultImage = CCSprite::create;
defaultImage~~>setPosition);
this~~>addChild(defaultImage);
CCTextureCache::sharedTextureCache()>addImageAsync);
this>schedule(schedule_selector(LoadingLayer::tick));
bRet = true;
} while (0);
return bRet;
}
void LoadingLayer::spritesLoaded(CCObject * object)
{
CCTexture2D * tex = static_castcocos2d::CCTexture2D*(object);
CCSpriteFrameCache::sharedSpriteFrameCache()>addSpriteFramesWithFile;
batchNode = CCSpriteBatchNode::createWithTexture;
this>addChild(batchNode);
main_bkgrnd = CCSprite::createWithSpriteFrameName(“Turret_main_bkgrnd.png”);
main_bkgrnd~~>setPosition.height/2));
batchNode~~>addChild(main_bkgrnd);
main_title = CCSprite::createWithSpriteFrameName(“Turret_main_title.png”);
main_title~~>setPosition.height/2-MAIN_TITLE_TOP_MARGIN));
batchNode~~>addChild(main_title);
tom = CCSprite::createWithSpriteFrameName(“Tom.png”);
tom~~>setPosition.width/2, winSize.height-main_title~~>getContentSize().height/2-MAIN_TITLE_TOP_MARGIN));
batchNode~~>addChild;
CCArray * blinkAnimFrames = CCArray::createWithCapacity;
blinkAnimFrames~~>addObject(CCSpriteFrameCache::sharedSpriteFrameCache()>spriteFrameByName);
blinkAnimFrames>addObject(CCSpriteFrameCache::sharedSpriteFrameCache()>spriteFrameByName);
blinkAnimFrames>addObject(CCSpriteFrameCache::sharedSpriteFrameCache()>spriteFrameByName);
CCAnimation * blinkAnimation = CCAnimation::createWithSpriteFrames;
CCAnimate * blinkAnimate = CCAnimate::create;
CCFiniteTimeAction * tomSeqAct = CCSequence::create, NULL);
CCAction * rep = CCRepeatForever::createtomSeqAct);
tom>runAction(rep);
loading = CCSprite::createWithSpriteFrameName(“Turret_loading.png”);
loading~~>setPosition.width) / 2) + tom~~>getContentSize().width,
loading~~>getContentSize.height/2 + LOADIN_BOTTOM_MARGIN));
batchNode~~>addChild(loading);
CCFiniteTimeAction * loadingSeqAct = CCSequence::create(CCFadeOut::create(1.0f), CCFadeIn::create(1.0f), NULL);
CCAction * rep2 = CCRepeatForever::create((CCActionInterval*)loadingSeqAct);
loading~~>runAction;
this~~>removeChild(defaultImage, true);
imagesLoaded = true;
}