bool CCActivityIndicator::init()
{
    auto spritecache = SpriteFrameCache::getInstance();
    
    spritecache->addSpriteFramesWithFile("ccactivityindicator.plist");
    CCSpriteBatchNode::initWithFile("ccactivityindicator.png", 1);
    
    Size winSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    indicator = CCSprite::createWithSpriteFrameName("ccactivityindicator_1.gif");
    indicator->setPosition(Vec2(winSize.width/2,winSize.height/2));
    addChild(indicator);
    
    animating = false;
    hidesWhenStopped = true;
    
//    beginCallback = NULL;
//    endCallback =


    //load all sprite frames into array
    for (int i=1; i<=kActivityIndicatorFramesCount; i++) {
        SpriteFrame * frame = spritecache->getSpriteFrameByName(CCString::createWithFormat("ccactivityindicator_%d.gif",i)->getCString());
        frame->retain();
        spriteFrames.pushBack(frame);
    }
    
    return true;
}
示例#2
0
    void prepareAnimation(cocos2d::Vector<cocos2d::SpriteFrame *> &frameArray, const std::string &animation, int numberOfFrame){
//        CCLOG("%s, %s, %d", __func__, animation.c_str(), numberOfFrame);
        
        for (int frameIndex = 0; frameIndex < numberOfFrame; ++frameIndex){
            std::string frameName = getMonsterAnimationFrameName(_name, animation, frameIndex);
//            CCLOG("Monster 动画名字:%s", frameName.c_str());
            frameArray.pushBack(getMonsterSpriteFrameByName(frameName));
        }
    }
示例#3
0
void ScrollDoubleLayer::creatMenuScrollItem(cocos2d::Vector<WJScrollItem*> &items, int count, const char *key)
{
	m_vectorMenuItem.clear();
	for (int i = 0; i < count; i++)
	{
		ScrollMenuItem *scrollItem = ScrollMenuItem::create(this, key, i, ScrollDragDir::StopDrag, true);
		scrollItem->setClickScrollItemEvent(CC_CALLBACK_3(ScrollDoubleLayer::_doEventMenuScrollItemClick, this));
		// 默认选中了第一个
		if (i == 0) scrollItem->setItemSelect(true);

		std::string itemKey = key;
		WJUtils::stringAddInt(itemKey, i + 1, 3);
		ScrollItemTemplate object = ScrollItemTemplateTem(itemKey);
		WJScrollItem* item = WJScrollItem::create(scrollItem, 0, scrollItem->getContentSize().height + object.itemsInterval);
		items.pushBack(item);

		// 当前1级菜单的数组
		m_vectorMenuItem.push_back(scrollItem);
	}
}
示例#4
0
void initMenuItems(cocos2d::Vector<cocos2d::MenuItem*>& menuItems, const std::string& name, const ccMenuCallback& callback) {
    MenuItemFont *menuItem = MenuItemFont::create(name, callback);
    menuItems.pushBack(menuItem);
}