当前位置: 首页>>代码示例>>C++>>正文


C++ CC_BREAK_IF函数代码示例

本文整理汇总了C++中CC_BREAK_IF函数的典型用法代码示例。如果您正苦于以下问题:C++ CC_BREAK_IF函数的具体用法?C++ CC_BREAK_IF怎么用?C++ CC_BREAK_IF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CC_BREAK_IF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CC_BREAK_IF

cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName, AttachComponentType attachComponent /*= AttachComponentType::EMPTY_NODE*/)
{
    std::string fileExtension = cocos2d::FileUtils::getInstance()->getFileExtension(fileName);
    if (fileExtension == ".json")
    {
        _node = nullptr;
        rapidjson::Document jsonDict;
        do {
            CC_BREAK_IF(!readJson(fileName, jsonDict));
            _node = createObject(jsonDict, nullptr, attachComponent);
            TriggerMng::getInstance()->parse(jsonDict);
        } while (0);
        
        return _node;
    }
    else if(fileExtension == ".csb")
    {
        do {
            std::string binaryFilePath = FileUtils::getInstance()->fullPathForFilename(fileName);
            auto fileData = FileUtils::getInstance()->getDataFromFile(binaryFilePath);
            auto fileDataBytes = fileData.getBytes();
            CC_BREAK_IF(fileData.isNull());
            CocoLoader tCocoLoader;
            if (tCocoLoader.ReadCocoBinBuff((char*)fileDataBytes))
            {
                stExpCocoNode *tpRootCocoNode = tCocoLoader.GetRootCocoNode();
                rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader);
                if (rapidjson::kObjectType  == tType)
                {
                    stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader);
                    CC_BREAK_IF(tpRootCocoNode->GetChildNum() == 0);
                    _node = Node::create();
                    int  nCount = 0;
                    std::vector<Component*> _vecComs;
                    ComRender *pRender = nullptr;
                    std::string key = tpChildArray[15].GetName(&tCocoLoader);
                    if (key == "components")
                    {
                        nCount = tpChildArray[15].GetChildNum();
                    }
                    stExpCocoNode *pComponents = tpChildArray[15].GetChildArray(&tCocoLoader);
                    SerData *data = new (std::nothrow) SerData();
                    for (int i = 0; i < nCount; i++)
                    {
                        stExpCocoNode *subDict = pComponents[i].GetChildArray(&tCocoLoader);
                        if (subDict == nullptr)
                        {
                            continue;
                        }
                        std::string key1 = subDict[1].GetName(&tCocoLoader);
                        const char *comName = subDict[1].GetValue(&tCocoLoader);
                        Component *pCom = nullptr;
                        if (key1 == "classname" && comName != nullptr)
                        {
                            pCom = createComponent(comName);
                        }
                        CCLOG("classname = %s", comName);
                        if (pCom != nullptr)
                        {
                            data->_rData = nullptr;
                            data->_cocoNode = subDict;
                            data->_cocoLoader = &tCocoLoader;
                            if (pCom->serialize(data))
                            {
                                ComRender *pTRender = dynamic_cast<ComRender*>(pCom);
                                if (pTRender != nullptr)
                                {
                                    pRender = pTRender;
                                }
                                else
                                {
                                    _vecComs.push_back(pCom);
                                }
                            }
                            else
                            {
                                CC_SAFE_RELEASE_NULL(pCom);
                            }
                        }
                        if(_fnSelector != nullptr)
                        {
                            _fnSelector(pCom, (void*)(data));
                        }
                    }
                    
                    setPropertyFromJsonDict(&tCocoLoader, tpRootCocoNode, _node);
                    for (std::vector<Component*>::iterator iter = _vecComs.begin(); iter != _vecComs.end(); ++iter)
                    {
                        _node->addComponent(*iter);
                    }
                    
                    stExpCocoNode *pGameObjects = tpChildArray[11].GetChildArray(&tCocoLoader);
                    int length = tpChildArray[11].GetChildNum();
                    for (int i = 0; i < length; ++i)
                    {
                        createObject(&tCocoLoader, &pGameObjects[i], _node, attachComponent);
                    }
                    TriggerMng::getInstance()->parse(&tCocoLoader, tpChildArray);
                }
                
//.........这里部分代码省略.........
开发者ID:CienProject2016,项目名称:VESS,代码行数:101,代码来源:CCSSceneReader.cpp

示例2: CCASSERT

/* get buffer as Image */
Image* RenderTexture::newImage(bool fliimage)
{
    CCASSERT(_pixelFormat == Texture2D::PixelFormat::RGBA8888, "only RGBA8888 can be saved as image");

    if (nullptr == _texture)
    {
        return nullptr;
    }

    const Size& s = _texture->getContentSizeInPixels();

    // to get the image size to save
    //        if the saving image domain exceeds the buffer texture domain,
    //        it should be cut
    int savedBufferWidth = (int)s.width;
    int savedBufferHeight = (int)s.height;

    GLubyte *buffer = nullptr;
    GLubyte *tempData = nullptr;
    Image *image = new (std::nothrow) Image();

    do
    {
        CC_BREAK_IF(! (buffer = new (std::nothrow) GLubyte[savedBufferWidth * savedBufferHeight * 4]));

        if(! (tempData = new (std::nothrow) GLubyte[savedBufferWidth * savedBufferHeight * 4]))
        {
            delete[] buffer;
            buffer = nullptr;
            break;
        }

        glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO);
        glBindFramebuffer(GL_FRAMEBUFFER, _FBO);

        // TODO: move this to configuration, so we don't check it every time
        /*  Certain Qualcomm Andreno gpu's will retain data in memory after a frame buffer switch which corrupts the render to the texture. The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. Create a temporary texture to overcome this. At the end of RenderTexture::begin(), switch the attached texture to the second one, call glClear, and then switch back to the original texture. This solution is unnecessary for other devices as they don't have the same issue with switching frame buffers.
         */
        if (Configuration::getInstance()->checkForGLExtension("GL_QCOM"))
        {
            // -- bind a temporary texture so we can clear the render buffer without losing our texture
            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _textureCopy->getName(), 0);
            CHECK_GL_ERROR_DEBUG();
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texture->getName(), 0);
        }
        glPixelStorei(GL_PACK_ALIGNMENT, 1);
        glReadPixels(0,0,savedBufferWidth, savedBufferHeight,GL_RGBA,GL_UNSIGNED_BYTE, tempData);
        glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO);

        if ( fliimage ) // -- flip is only required when saving image to file
        {
            // to get the actual texture data
            // #640 the image read from rendertexture is dirty
            for (int i = 0; i < savedBufferHeight; ++i)
            {
                memcpy(&buffer[i * savedBufferWidth * 4],
                       &tempData[(savedBufferHeight - i - 1) * savedBufferWidth * 4],
                       savedBufferWidth * 4);
            }

            image->initWithRawData(buffer, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8);
        }
        else
        {
            image->initWithRawData(tempData, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8);
        }
        
    } while (0);

    CC_SAFE_DELETE_ARRAY(buffer);
    CC_SAFE_DELETE_ARRAY(tempData);

    return image;
}
开发者ID:mynameis7,项目名称:Cocos2dx-TestProject,代码行数:76,代码来源:CCRenderTexture.cpp

示例3: CC_BREAK_IF

bool CCEGLView::Create()
{
    bool bRet = false;
    do
    {
        CC_BREAK_IF(m_hWnd);

        HINSTANCE hInstance = GetModuleHandle( NULL );
        WNDCLASS  wc;        // Windows Class Structure

		// set the wnd icon
		HICON hIcon = LoadIcon( hInstance, MAKEINTRESOURCE(MAKEFOURCC('c', 'c', '2', 'd')) );
		if (!hIcon)
			hIcon = LoadIcon( NULL, IDI_WINLOGO );

        // Redraw On Size, And Own DC For Window.
        wc.style          = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
        wc.lpfnWndProc    = _WindowProc;                    // WndProc Handles Messages
        wc.cbClsExtra     = 0;                              // No Extra Window Data
        wc.cbWndExtra     = 0;                                // No Extra Window Data
        wc.hInstance      = hInstance;                        // Set The Instance
        wc.hIcon          = hIcon;							// Load The Default Icon
        wc.hCursor        = LoadCursor( NULL, IDC_ARROW );    // Load The Arrow Pointer
        wc.hbrBackground  = NULL;                           // No Background Required For GL
        wc.lpszMenuName   = m_menu;                         //
        wc.lpszClassName  = kWindowClassName;               // Set The Class Name

        CC_BREAK_IF(! RegisterClass(&wc) && 1410 != GetLastError());

        // center window position
        RECT rcDesktop;
        GetWindowRect(GetDesktopWindow(), &rcDesktop);

        WCHAR wszBuf[50] = {0};
        MultiByteToWideChar(CP_UTF8, 0, m_szViewName, -1, wszBuf, sizeof(wszBuf));

        // create window
        m_hWnd = CreateWindowEx(
            WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,    // Extended Style For The Window
            kWindowClassName,                                    // Class Name
            wszBuf,                                                // Window Title
            WS_CAPTION | WS_POPUPWINDOW | WS_MINIMIZEBOX,        // Defined Window Style
            0, 0,                                                // Window Position
            //TODO: Initializing width with a large value to avoid getting a wrong client area by 'GetClientRect' function.
            1000,                                               // Window Width
            1000,                                               // Window Height
            NULL,                                                // No Parent Window
            NULL,                                                // No Menu
            hInstance,                                            // Instance
            NULL );

        CC_BREAK_IF(! m_hWnd);

        bRet = initGL();
		if(!bRet) destroyGL();
        CC_BREAK_IF(!bRet);

        s_pMainWindow = this;
        bRet = true;
    } while (0);

#if(_MSC_VER >= 1600)
    m_bSupportTouch = CheckTouchSupport();
    if(m_bSupportTouch)
	{
	    m_bSupportTouch = (s_pfRegisterTouchWindowFunction(m_hWnd, 0) != 0);
    }
#endif /* #if(_MSC_VER >= 1600) */

    return bRet;
}
开发者ID:HerdiandKun,项目名称:cocos3d-x,代码行数:71,代码来源:CCEGLView.cpp

示例4: ccp

bool S4HeZuo::setUpSubClass()
{
	bool bRet = false;
	do
	{
        float firstStrFontSize = ScriptParser::getFontSizeFromPlist(plistDic,"firstTitle");
        CCLabelTTF *firstTitleLabel = CCLabelTTF::create(ScriptParser::getStringFromPlist(plistDic,"firstTitle"), s1FontName_macro, firstStrFontSize);
        firstTitleLabel->setColor(ccc3(193.0,159.0,113.0));
        firstTitleLabel->setPosition(ScriptParser::getPositionFromPlist(plistDic,"firstTitle"));
        this->addChild(firstTitleLabel,zNum+1);
        
        CCSprite * S1PSubBottomSprite = CCSprite::create("S1PSubBottom.png");
        S1PSubBottomSprite->setPosition( ccp(origin.x+visibleSize.width/2,firstTitleLabel->getPosition().y-firstTitleLabel->getContentSize().height/2-10));
        this->addChild(S1PSubBottomSprite,zNum);
        
        
        map<string, string> naviGroupStrMap =  ScriptParser::getGroupStringFromPlist(plistDic,"naviTitle");
        float naviFontSize = ScriptParser::getFontSizeFromPlist(plistDic,"naviTitle");
        CCPoint naviStrPosition = ScriptParser::getPositionFromPlist(plistDic,"naviTitle");
        
        for (int i=0; i<(int)naviGroupStrMap.size(); i++)
        {
            const char * labelStr = naviGroupStrMap[PersonalApi::convertIntToString(i+1)].c_str();
            
            CCLabelTTF *pLabel = CCLabelTTF::create(labelStr, s1FontName_macro, naviFontSize);
            pLabel->setPosition(ccp(naviStrPosition.x+(pLabel->getContentSize().width+20)*i,naviStrPosition.y));
            pLabel->setColor(ccc3(128.0,128.0,128.0));
            this->addChild(pLabel,zNum+1);
            
            if ( AppDelegate::S4SelectNavi == i+1)
            {
                pLabel->setColor(ccc3(255.0,255.0,255.0));
                CCSprite * selectFrameSprite = CCSprite::create("PSubNavBackground.png");
                selectFrameSprite->setScaleX(pLabel->getContentSize().width/selectFrameSprite->getContentSize().width);
                selectFrameSprite ->setPosition(pLabel->getPosition());
                this->addChild(selectFrameSprite,zNum);
            }
            
            CCSprite * sprite1 = CCSprite::create();
			CCSprite * sprite2 = CCSprite::create();
            
			CCMenuItemSprite *aItem = CCMenuItemSprite::create(
                                                               sprite1,
                                                               sprite2,
                                                               this,
                                                               menu_selector(S4HeZuo::menuCallback));
			CC_BREAK_IF(! aItem);
			aItem->setPosition(pLabel->getPosition());
            aItem->setContentSize(pLabel->getContentSize());
            aItem->setTag(btnTag+i+1);
			_menu ->addChild(aItem,zNum);
            
        }
        
        CC_BREAK_IF(! setUpSubClass2());
        
		bRet = true;
	} while (0);
    
	return bRet;
}
开发者ID:Ratel13,项目名称:JinRiCompany,代码行数:61,代码来源:S4HeZuo.cpp

示例5: CC_BREAK_IF

bool GameSceneLayer::init(){
	bool bRet = false;
	do{
		CC_BREAK_IF(!CCLayer::init());
		setKeypadEnabled(true);

		//CCLOG("init1");
		//创建物理世界
		b2Vec2 gravity;
		gravity.Set(0.0f,-10.0f);
		m_pMyworld = new b2World(gravity);
		m_pMyworld->SetAllowSleeping(true);

		m_pMyContactListener = new MyContactListener();
		m_pMyworld->SetContactListener(m_pMyContactListener);

		//m_pDebugDraw = new GLESDebugDraw( PT_RATIO );
		//m_pMyworld->SetDebugDraw(m_pDebugDraw);
		//uint32 flags = 0;
		//flags += b2Draw::e_shapeBit;
		//flags += b2Draw::e_jointBit;
		//flags += b2Draw::e_aabbBit;
		//flags += b2Draw::e_pairBit;
		//flags += b2Draw::e_centerOfMassBit;
		//m_pDebugDraw->SetFlags(flags);

		//创建一个地面
		//b2BodyDef groundboxDef;
		////groundboxDef.

		//b2Body *groundBody = m_pMyworld->CreateBody(&groundboxDef);
	
		//b2EdgeShape groundbox;
		////groundbox.m_type
		//groundbox.Set(b2Vec2(0,220/32),b2Vec2(640.0f/32,220/32));
		//groundBody->CreateFixture(&groundbox,0);

		//groundbox.Set(b2Vec2(0,0/32),b2Vec2(0,480.0f/32));
		//groundBody->CreateFixture(&groundbox,0);

		//groundbox.Set(b2Vec2(640.0f/32,0/32),b2Vec2(640.0f/32,480.0f/32));
		//groundBody->CreateFixture(&groundbox,0);

		//groundbox.Set(b2Vec2(0,480.0f/32),b2Vec2(640.0f/32,480.0f/32));
		//groundBody->CreateFixture(&groundbox,0);

		//创建几个动态刚体

		//for (int i = 0; i < 4; i++){

		//	CCSprite *sprite = CCSprite::create("image 277.png");
		//	sprite->setPosition(ccp(200+100*i,200));
		//	addChild(sprite);
		//	addBoxbodyFromSprite(sprite);
		//	//b2BodyDef bodydef;
		//	//bodydef.type = b2_dynamicBody;
		//	//bodydef.position.Set(200/32+100/32*i,200/32);

		//	//b2Body *body = m_pMyworld->CreateBody(&bodydef);

		//	//b2PolygonShape dynamicbox;
		//	//dynamicbox.SetAsBox(0.5f,0.5f);

		//	//b2FixtureDef fixturedef;
		//	//fixturedef.shape = &dynamicbox;
		//	//fixturedef.density = 1.0f;
		//	//fixturedef.friction = 0.3f;
		//	//fixturedef.restitution = 0.5f;
		//	//body->CreateFixture(&fixturedef);
		//}

		//init 
		CCSprite* bg;
		if (Setting::g_icurrentGate < 10)
		{
			 bg = CCSprite::create("gamebg_1.png");
		}else
		{
		  bg = CCSprite::create("gamebg_2.png");
		}
		bg->setPosition(ccp(Setting::g_ResolusionWidth/2,Setting::g_ResolusionHeight/2));
		addChild(bg,-1);

		m_bDrawlineFlag = false;
		m_LineEndpos = m_LineStartpos = ccp(105,155);

		m_iResuduoMonsterNum = 0;
		//CCLOG("init2");
		initTiledMap();


		//添加一个炮台
		CCSprite*cannonSprite = CCSprite::createWithSpriteFrameName("cannon.png");
		addChild(cannonSprite,1);
		cannonSprite->setPosition(ccp(105,155));
		cannonSprite->setTag(m_iCannonSpriteTag);

		CCSprite*batterySprite = CCSprite::createWithSpriteFrameName("battery.png");
		addChild(batterySprite,1);
		batterySprite->setPosition(ccp(100,140));
//.........这里部分代码省略.........
开发者ID:joyfish,项目名称:bombZombie,代码行数:101,代码来源:GameSceneLayer.cpp

示例6: CC_BREAK_IF

KDbool Image::initWithImageData ( const KDubyte* pData, KDint32 nDataLen )
{
	KDbool	bRet = false;

	do
	{
		CC_BREAK_IF ( !pData || nDataLen <= 0 );

		KDubyte*	pUnpackedData = nullptr;
		KDint		nUnpackedLen = 0;

		// detecgt and unzip the compress file
		if ( ZipUtils::isCCZBuffer ( pData, nDataLen ) )
		{
			nUnpackedLen = ZipUtils::inflateCCZBuffer ( pData, nDataLen, &pUnpackedData );
		}
		else if ( ZipUtils::isGZipBuffer ( pData, nDataLen ) )
		{
			nUnpackedLen = ZipUtils::inflateMemory ( const_cast<KDubyte*> ( pData ), nDataLen, &pUnpackedData );
		}
		else
		{
			pUnpackedData = const_cast<KDubyte*> ( pData );
			nUnpackedLen = nDataLen;
		}

		KDFile*		pFile   = kdFmemopen ( pUnpackedData, nUnpackedLen, "rb" );
		KDoff		uOffset = kdFtell ( pFile );
		KDImageATX	pImage  = KD_NULL;

		do 
		{
			Texture2D::PixelFormat  eFormat = Texture2D::getDefaultAlphaPixelFormat ( );
			
			if ( eFormat == Texture2D::PixelFormat::AUTO )
			{			
				pImage = kdGetImageInfoFromStreamATX ( pFile );
				CC_BREAK_IF ( !pImage );

				KDint  nFormat = kdGetImageIntATX ( pImage, KD_IMAGE_FORMAT_ATX );
				KDint  nBpp    = kdGetImageIntATX ( pImage, KD_IMAGE_BITSPERPIXEL_ATX );
				KDint  nAlpha  = kdGetImageIntATX ( pImage, KD_IMAGE_ALPHA_ATX );
				KDint  nType   = kdGetImageIntATX ( pImage, KD_IMAGE_TYPE );

				m_eFileType = (Format) nType;
		
				kdFreeImageATX ( pImage );
				kdFseek ( pFile, uOffset, KD_SEEK_SET );

				switch ( nFormat )
				{
					case KD_IMAGE_FORMAT_COMPRESSED_ATX :	
						if ( ( nType == KD_IMAGE_TYPE_PVR   && !Configuration::getInstance ( )->supportsPVRTC ( ) ) ||
							 ( nType == KD_IMAGE_TYPE_S3TC  && !Configuration::getInstance ( )->supportsS3TC  ( ) ) ||
							 ( nType == KD_IMAGE_TYPE_ATITC && !Configuration::getInstance ( )->supportsATITC ( ) ) ||
							 ( nType == KD_IMAGE_TYPE_ETC   && !Configuration::getInstance ( )->supportsETC   ( ) ) )
						{
							eFormat = Texture2D::PixelFormat::RGBA8888;
						}
						else
						{
							eFormat = Texture2D::PixelFormat::COMPRESSED;
						}
						break;

					case KD_IMAGE_FORMAT_ALPHA8_ATX:
						eFormat = Texture2D::PixelFormat::A8;
						break;

					case KD_IMAGE_FORMAT_LUMINANCE_ATX:
						eFormat = Texture2D::PixelFormat::I8;
						break;

					case KD_IMAGE_FORMAT_LUMALPHA_ATX:
						eFormat = Texture2D::PixelFormat::AI88;
						break;

					case KD_IMAGE_FORMAT_PALETTED_ATX:
						eFormat = Texture2D::PixelFormat::RGB5A1;
						break;

					case KD_IMAGE_FORMAT_RGB_ATX:
						if ( nBpp == 24 || nBpp == 48 )
						{
							eFormat = Texture2D::PixelFormat::RGB888;
						}
						else
						{
							eFormat = Texture2D::PixelFormat::RGB565;
						}						
						break;

					case KD_IMAGE_FORMAT_RGBA_ATX:
						if ( nBpp == 16 )
						{
							eFormat = ( nAlpha == 4 ) ? Texture2D::PixelFormat::RGBA4444 : Texture2D::PixelFormat::RGB5A1;
						}
						else
						{
							eFormat = Texture2D::PixelFormat::RGBA8888;
//.........这里部分代码省略.........
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:101,代码来源:CCImage.cpp

示例7: CC_BREAK_IF

bool GameSuccessfullyLayer::setUpdateView(){
	bool isRet=false;
	do
	{
		char temp[12];
		// 添加背景图片
		CCSprite* laybg=CCSprite::createWithTexture(CCTextureCache::sharedTextureCache()->textureForKey("stats_bg.png"));
		CC_BREAK_IF(!laybg);
		laybg->setPosition(getWinCenter());
		this->addChild(laybg);
		// 添加当前关卡
		CCLabelAtlas* stage= CCLabelAtlas::create("0","numtips.png",25,31,'0');
		CC_BREAK_IF(!stage);
		int lve=CCUserDefault::sharedUserDefault()->getIntegerForKey("lve",1);
	    sprintf(temp,"%d",lve);
		stage->setString(temp);
		stage->setAnchorPoint(ccp(0,0));
		stage->setPosition(ccp(415,370));
		this->addChild(stage,1);
		CCUserDefault::sharedUserDefault()->setIntegerForKey("lve",lve+1);
        
		// 添加击杀怪物数目
		CCLabelAtlas* killcount= CCLabelAtlas::create("0","numtips.png",25,31,'0');
		CC_BREAK_IF(!killcount);
		int killtemp=CCUserDefault::sharedUserDefault()->getIntegerForKey("killtemp",0);
		sprintf(temp,"%d",killtemp);
		killcount->setString(temp);
		killcount->setAnchorPoint(ccp(0,0));
		killcount->setPosition(ccp(415,320));
		this->addChild(killcount,1);
		CCUserDefault::sharedUserDefault()->setIntegerForKey("killtemp",0);
        
        
		// 显示剩余生命值
		CCLabelAtlas* lifecount= CCLabelAtlas::create("0","numtips.png",25,31,'0');
		CC_BREAK_IF(!lifecount);
		int lifetemp=CCUserDefault::sharedUserDefault()->getIntegerForKey("lifetemp",0);
		sprintf(temp,"%d",lifetemp);
		lifecount->setString(temp);
		lifecount->setAnchorPoint(ccp(0,0));
		lifecount->setPosition(ccp(415,280));
		this->addChild(lifecount,1);
		CCUserDefault::sharedUserDefault()->setIntegerForKey("lifetemp",0);
        
        
        
		// 显示击杀奖励 规定杀死一个怪经历1个金币
		CCLabelAtlas* killbound= CCLabelAtlas::create("0","numtips.png",25,31,'0');
		CC_BREAK_IF(!killbound);
		sprintf(temp,"%d",killtemp);
		killbound->setString(temp);
		killbound->setAnchorPoint(ccp(0,0));
		killbound->setPosition(ccp(440,218));
		this->addChild(killbound,1);
        
		// 显示生命值奖励 一点生命值奖励一个金币
		CCLabelAtlas* lifebound= CCLabelAtlas::create("0","numtips.png",25,31,'0');
		CC_BREAK_IF(!lifebound);
		sprintf(temp,"%d",lifetemp);
		lifebound->setString(temp);
		lifebound->setAnchorPoint(ccp(0,0));
		lifebound->setPosition(ccp(440,170));
		this->addChild(lifebound,1);
        
        
		// 显示关卡奖励 一个过一关奖励5个金币
		CCLabelAtlas* goldbound= CCLabelAtlas::create("0","numtips.png",25,31,'0');
		CC_BREAK_IF(!goldbound);
		sprintf(temp,"%d",lve*5);
		goldbound->setString(temp);
		goldbound->setAnchorPoint(ccp(0,0));
		goldbound->setPosition(ccp(440,132));
		this->addChild(goldbound,1);
        
        
		// 显示显示总奖励金币
		CCLabelAtlas* total= CCLabelAtlas::create("0","numtips.png",25,31,'0');
		CC_BREAK_IF(!total);
		int totalnum=lve*5+lifetemp+killtemp;
		sprintf(temp,"%d",totalnum);
		total->setString(temp);
		total->setAnchorPoint(ccp(0,0));
		total->setPosition(ccp(415,80));
		this->addChild(total,1);
        
		// 加上总金币
		int goldnum=CCUserDefault::sharedUserDefault()->getIntegerForKey("goldNum",0);
		CCUserDefault::sharedUserDefault()->setIntegerForKey("goldNum",totalnum+goldnum);
        
		// 创建当前提示信息
        
		CCSprite* tip=CCSprite::createWithTexture(CCTextureCache::sharedTextureCache()->textureForKey("statstip.png"));
		CC_BREAK_IF(!tip);
		tip->setPosition(ccp(this->getContentSize().width/2,30));
		this->addChild(tip,1);
		tip->runAction(CCRepeatForever::create(CCBlink::create(1,1)));
		
        
        isRet=true;
	} while (0);
//.........这里部分代码省略.........
开发者ID:joyfish,项目名称:cocos2d-1,代码行数:101,代码来源:GameSuccessfullyLayer.cpp

示例8: CC_BREAK_IF

bool GameScene::init(){
	bool bRet = false;
	do{
		CC_BREAK_IF(!CCLayer::init());
		setTouchEnabled(true);

		initBgItems(GameData::getLevel());

		//scrollBg1 = CCSprite::createWithTexture(scrollBg->getTexture());

		overText = CCLabelTTF::create("Game OVer!!!\nTouch screen to replay,Let's go","黑体",30);
		overText->setColor(ccc3(255,0,0));
		overText->setPosition(ccp(425,240));
		overText->setVisible(false);

		//CC_BREAK_IF(!scrollBg1);

		addChild(overText,1);
		//addChild(scrollBg1);
		//scrollBg1->setAnchorPoint(ccp(0,0));

		//scrollBg1->setPosition(ccp(scrollBg->getContentSize().width,0));
		//初始化地图
		map = new Map(1,this);
		//生成主角
		hero = new Role(this);

		CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("game.plist","game.png");
		CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("prop_effect.plist","prop_effect.png");
		initProps(200);

		CCSprite* scorePeach = CCSprite::createWithSpriteFrameName("score_peach.png");
		SETANCHPOS(scorePeach,600,420,0,0);
		addChild(scorePeach,10);


		CCSprite* distance = CCSprite::createWithSpriteFrameName("distance.png");
		SETANCHPOS(distance,0,430,0,0);
		addChild(distance,10);

		CCSprite* best = CCSprite::createWithSpriteFrameName("best.png");
		SETANCHPOS(best,20,390,0,0);
		addChild(best,10);

		scoreValue = CCLabelAtlas::create("0","num/num_green.png",28,40,'0');
		SETANCHPOS(scoreValue,680,420,0,0);
		addChild(scoreValue,10);

		distanceValue = CCLabelAtlas::create("0","num/num_yellow.png",28,40,'0');
		SETANCHPOS(distanceValue,170,430,0,0);
		addChild(distanceValue,10);

		char b[20];
		sprintf(b,"%d",GameData::getBest());
		bestValue = CCLabelAtlas::create(b,"num/num_red.png",28,40,'0');
		SETANCHPOS(bestValue,140,390,0,0);
		addChild(bestValue,10);

		progressBg = CCSprite::createWithSpriteFrameName("progress.png");
		SETANCHPOS(progressBg,200,0,0,0);
		addChild(progressBg,14);

		progressLeaf = CCSprite::createWithSpriteFrameName("thumb_leaf.png");
		SETANCHPOS(progressLeaf,200,0,0,0);
		addChild(progressLeaf,14);

		CCMenu* menu = CCMenu::create();
		SETANCHPOS(menu,20,0,0,0);
		menu->setTag(99);
		addChild(menu,12);

		CCMenuItemSprite* pause = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("pause.png"),
			CCSprite::createWithSpriteFrameName("pause.png"),this,menu_selector(GameScene::btnCallback));
		SETANCHPOS(pause,0,0,0,0);
		pause->setTag(1);
		menu->addChild(pause);


		schedule(schedule_selector(GameScene::bgMove));
		bRet = true;
	}while(0);
	return bRet;
}
开发者ID:rhzchina,项目名称:West,代码行数:83,代码来源:GameScene.cpp

示例9: CC_BREAK_IF

bool CCComRender::serialize(void* r)
{
    bool bRet = false;
    do 
    {
        CC_BREAK_IF(r == NULL);
		SerData *pSerData = (SerData *)(r);
        const rapidjson::Value *v = pSerData->prData;
		stExpCocoNode *pCocoNode = pSerData->pCocoNode;
		CocoLoader *pCocoLoader = pSerData->pCocoLoader;
		const char *pClassName = NULL;
		const char *pComName = NULL;
		const char *pFile = NULL;
		const char *pPlist = NULL;
		std::string strFilePath;
		std::string strPlistPath;
		int nResType = 0;
		if (v != NULL)
		{
			pClassName = DICTOOL->getStringValue_json(*v, "classname");
			CC_BREAK_IF(pClassName == NULL);
			pComName = DICTOOL->getStringValue_json(*v, "name");
			const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData");
			CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData));
			pFile = DICTOOL->getStringValue_json(fileData, "path");
			pPlist = DICTOOL->getStringValue_json(fileData, "plistFile");
			CC_BREAK_IF(pFile == NULL && pPlist == NULL);
			nResType = DICTOOL->getIntValue_json(fileData, "resourceType", -1);
		}
		else if(pCocoNode != NULL)
		{
			pClassName = pCocoNode[1].GetValue(pCocoLoader);
			CC_BREAK_IF(pClassName == NULL);
			pComName = pCocoNode[2].GetValue(pCocoLoader);
			stExpCocoNode *pfileData = pCocoNode[4].GetChildArray(pCocoLoader);
			CC_BREAK_IF(!pfileData);
			pFile = pfileData[0].GetValue(pCocoLoader); 
			pPlist = pfileData[1].GetValue(pCocoLoader); 
			CC_BREAK_IF(pFile == NULL && pPlist == NULL);
			nResType = atoi(pfileData[2].GetValue(pCocoLoader));
		}  
		if (pComName != NULL)
		{
			setName(pComName);
		}
		else
		{
			setName(pClassName);
		}

		if (pFile != NULL)
		{
			strFilePath.assign(cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(pFile));
		}
		if (pPlist != NULL)
		{
			strPlistPath.assign(cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(pPlist));
		}
		if (nResType == 0)
		{
			if (strcmp(pClassName, "CCSprite") == 0 && (strFilePath.find(".png") != strFilePath.npos || strFilePath.find(".pvr.ccz") != strFilePath.npos))
			{
				m_pRender = CCSprite::create(strFilePath.c_str());
				m_pRender->retain();

                bRet = true;
			}
			else if(strcmp(pClassName, "CCTMXTiledMap") == 0 && strFilePath.find(".tmx") != strFilePath.npos)
			{
				m_pRender = CCTMXTiledMap::create(strFilePath.c_str());
				m_pRender->retain();

                bRet = true;
			}
			else if(strcmp(pClassName, "CCParticleSystemQuad") == 0 && strFilePath.find(".plist") != strFilePath.npos)
			{
				m_pRender = CCParticleSystemQuad::create(strFilePath.c_str());
				m_pRender->setPosition(ccp(0.0f, 0.0f));
				m_pRender->retain();

                bRet = true;
			}
			else if(strcmp(pClassName, "CCArmature") == 0)
			{
				std::string file_extension = strFilePath;
				size_t pos = strFilePath.find_last_of('.');
				if (pos != std::string::npos)
				{
					file_extension = strFilePath.substr(pos, strFilePath.length());
					std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper);
				}
				if (file_extension == ".JSON" || file_extension == ".EXPORTJSON")
				{
					rapidjson::Document doc;
					if(!readJson(strFilePath.c_str(), doc))
					{
						CCLog("read json file[%s] error!\n", strFilePath.c_str());
						continue;
					}
					const rapidjson::Value &subData = DICTOOL->getDictionaryFromArray_json(doc, "armature_data", 0);
//.........这里部分代码省略.........
开发者ID:1085075003,项目名称:quick-cocos2d-x,代码行数:101,代码来源:CCComRender.cpp

示例10: CC_BREAK_IF

bool CCImage::_saveImageToPNG(const char * pszFilePath, bool bIsToRGB)
{
	bool bRet = false;
	do 
	{
		CC_BREAK_IF(NULL == pszFilePath);

		FILE *fp;
		png_structp png_ptr;
		png_infop info_ptr;
		png_colorp palette;
		png_bytep *row_pointers;

		fp = fopen(pszFilePath, "wb");
		CC_BREAK_IF(NULL == fp);

		png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);

		if (NULL == png_ptr)
		{
			fclose(fp);
			break;
		}

		info_ptr = png_create_info_struct(png_ptr);
		if (NULL == info_ptr)
		{
			fclose(fp);
			png_destroy_write_struct(&png_ptr, NULL);
			break;
		}
#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA)
		if (setjmp(png_jmpbuf(png_ptr)))
		{
			fclose(fp);
			png_destroy_write_struct(&png_ptr, &info_ptr);
			break;
		}
#endif
		png_init_io(png_ptr, fp);

		if (!bIsToRGB && m_bHasAlpha)
		{
			png_set_IHDR(png_ptr, info_ptr, m_nWidth, m_nHeight, 8, PNG_COLOR_TYPE_RGB_ALPHA,
				PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
		} 
		else
		{
			png_set_IHDR(png_ptr, info_ptr, m_nWidth, m_nHeight, 8, PNG_COLOR_TYPE_RGB,
				PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
		}

		palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH * sizeof (png_color));
		png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);

		png_write_info(png_ptr, info_ptr);

		png_set_packing(png_ptr);

		row_pointers = (png_bytep *)malloc(m_nHeight * sizeof(png_bytep));
		if(row_pointers == NULL)
		{
			fclose(fp);
			png_destroy_write_struct(&png_ptr, &info_ptr);
			break;
		}

		if (!m_bHasAlpha)
		{
			for (int i = 0; i < (int)m_nHeight; i++)
			{
				row_pointers[i] = (png_bytep)m_pData + i * m_nWidth * 3;
			}

			png_write_image(png_ptr, row_pointers);

			free(row_pointers);
			row_pointers = NULL;
		}
		else
		{
			if (bIsToRGB)
			{
				unsigned char *pTempData = new unsigned char[m_nWidth * m_nHeight * 3];
				if (NULL == pTempData)
				{
					fclose(fp);
					png_destroy_write_struct(&png_ptr, &info_ptr);
					break;
				}

				for (int i = 0; i < m_nHeight; ++i)
				{
					for (int j = 0; j < m_nWidth; ++j)
					{
						pTempData[(i * m_nWidth + j) * 3] = m_pData[(i * m_nWidth + j) * 4];
						pTempData[(i * m_nWidth + j) * 3 + 1] = m_pData[(i * m_nWidth + j) * 4 + 1];
						pTempData[(i * m_nWidth + j) * 3 + 2] = m_pData[(i * m_nWidth + j) * 4 + 2];
					}
				}
//.........这里部分代码省略.........
开发者ID:AfterTheRainOfStars,项目名称:cocos2d-x-qt,代码行数:101,代码来源:CCImage.cpp

示例11: jpeg_std_error

bool CCImage::_initWithJpgData(void * data, int nSize)
{
    /* these are standard libjpeg structures for reading(decompression) */
    struct jpeg_decompress_struct cinfo;
    struct jpeg_error_mgr jerr;
    /* libjpeg data structure for storing one row, that is, scanline of an image */
    JSAMPROW row_pointer[1] = {0};
    unsigned long location = 0;
    unsigned int i = 0;

    bool bRet = false;
    do 
    {
        /* here we set up the standard libjpeg error handler */
        cinfo.err = jpeg_std_error( &jerr );

        /* setup decompression process and source, then read JPEG header */
        jpeg_create_decompress( &cinfo );

        jpeg_mem_src( &cinfo, (unsigned char *) data, nSize );

        /* reading the image header which contains image information */
        jpeg_read_header( &cinfo, true );

        // we only support RGB or grayscale
        if (cinfo.jpeg_color_space != JCS_RGB)
        {
            if (cinfo.jpeg_color_space == JCS_GRAYSCALE || cinfo.jpeg_color_space == JCS_YCbCr)
            {
                cinfo.out_color_space = JCS_RGB;
            }
        }
        else
        {
            break;
        }

        /* Start decompression jpeg here */
        jpeg_start_decompress( &cinfo );

        /* init image info */
        m_nWidth  = (short)(cinfo.image_width);
        m_nHeight = (short)(cinfo.image_height);
        m_bHasAlpha = false;
        m_bPreMulti = false;
        m_nBitsPerComponent = 8;
        row_pointer[0] = new unsigned char[cinfo.output_width*cinfo.output_components];
        CC_BREAK_IF(! row_pointer[0]);

        m_pData = new unsigned char[cinfo.output_width*cinfo.output_height*cinfo.output_components];
        CC_BREAK_IF(! m_pData);

        /* now actually read the jpeg into the raw buffer */
        /* read one scan line at a time */
        while( cinfo.output_scanline < cinfo.image_height )
        {
            jpeg_read_scanlines( &cinfo, row_pointer, 1 );
            for( i=0; i<cinfo.image_width*cinfo.num_components;i++) 
                m_pData[location++] = row_pointer[0][i];
        }

        jpeg_finish_decompress( &cinfo );
        jpeg_destroy_decompress( &cinfo );
        /* wrap up decompression, destroy objects, free pointers and close open files */        
        bRet = true;
    } while (0);

    CC_SAFE_DELETE_ARRAY(row_pointer[0]);
    return bRet;
}
开发者ID:AfterTheRainOfStars,项目名称:cocos2d-x-qt,代码行数:70,代码来源:CCImage.cpp

示例12: CC_BREAK_IF

bool ComAudio::serialize(void* r)
{
    bool ret = false;
    do
    {
        CC_BREAK_IF(r == nullptr);
        SerData *serData = (SerData *)(r);
        const rapidjson::Value *v = serData->_rData;
        stExpCocoNode *cocoNode = serData->_cocoNode;
        CocoLoader *cocoLoader = serData->_cocoLoader;
        const char *className = nullptr;
        const char *comName = nullptr;
        const char *file = nullptr;
        std::string filePath;
        int resType = 0;
        bool loop = false;
        if (v != nullptr)
        {
            className = DICTOOL->getStringValue_json(*v, "classname");
            CC_BREAK_IF(className == nullptr);
            comName = DICTOOL->getStringValue_json(*v, "name");
            const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData");
            CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData));
            file = DICTOOL->getStringValue_json(fileData, "path");
            CC_BREAK_IF(file == nullptr);
            resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1);
            CC_BREAK_IF(resType != 0);
            loop = DICTOOL->getIntValue_json(*v, "loop") != 0? true:false;
        }
        else if (cocoNode != nullptr)
        {
            className = cocoNode[1].GetValue(cocoLoader);
            CC_BREAK_IF(className == nullptr);
            comName = cocoNode[2].GetValue(cocoLoader);
            stExpCocoNode *pfileData = cocoNode[4].GetChildArray(cocoLoader);
            CC_BREAK_IF(!pfileData);
            file = pfileData[0].GetValue(cocoLoader);
            CC_BREAK_IF(file == nullptr);
            resType = atoi(pfileData[2].GetValue(cocoLoader));
            CC_BREAK_IF(resType != 0);
            loop = atoi(cocoNode[5].GetValue(cocoLoader)) != 0? true:false;
            ret = true;
        }
        if (comName != nullptr)
        {
            setName(comName);
        }
        else
        {
            setName(className);
        }
        if (file != nullptr)
        {
            if (strcmp(file, "") == 0)
            {
                continue;
            }
            filePath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(file));
        }
        if (strcmp(className, "CCBackgroundAudio") == 0)
        {
            preloadBackgroundMusic(filePath.c_str());
            setLoop(loop);
            playBackgroundMusic(filePath.c_str(), loop);
        }
        else if(strcmp(className, COMPONENT_NAME.c_str()) == 0)
        {
            preloadEffect(filePath.c_str());
        }
        else
        {
            CC_BREAK_IF(true);
        }
        ret = true;
    }while (0);
    return ret;
}
开发者ID:253056965,项目名称:cocos2d-x-lite,代码行数:77,代码来源:CCComAudio.cpp

示例13: CCAssert

bool CARenderImage::initWithWidthAndHeight(int w, int h, CAImage::PixelFormat eFormat, GLuint uDepthStencilFormat)
{
    CCAssert(eFormat != CAImage::PixelFormat_A8, "only RGB and RGBA formats are valid for a render texture");

    bool bRet = false;
    unsigned char *data = NULL;
    do 
    {
        glGetIntegerv(GL_FRAMEBUFFER_BINDING, &m_nOldFBO);

        // textures must be power of two squared
        unsigned int powW = 0;
        unsigned int powH = 0;

        {
            powW = (unsigned int)w;
            powH = (unsigned int)h;
        }

        data = (unsigned char *)malloc((int)(powW * powH * 4));
        CC_BREAK_IF(! data);

        memset(data, 0, (int)(powW * powH * 4));
        m_ePixelFormat = eFormat;
        m_uPixelsWide = powW;
        m_uPixelsHigh = powH;
        
        glPixelStorei(GL_UNPACK_ALIGNMENT, 8);
        glGenTextures(1, &m_uName);
        ccGLBindTexture2D(m_uName);
        
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_uPixelsWide, m_uPixelsHigh, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
        
        GLint oldRBO;
        glGetIntegerv(GL_RENDERBUFFER_BINDING, &oldRBO);
        
        // generate FBO
        glGenFramebuffers(1, &m_uFBO);
        glBindFramebuffer(GL_FRAMEBUFFER, m_uFBO);

        // associate Image with FBO
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_uName, 0);

        if (uDepthStencilFormat != 0)
        {
            //create and attach depth buffer
            glGenRenderbuffers(1, &m_uDepthRenderBufffer);
            glBindRenderbuffer(GL_RENDERBUFFER, m_uDepthRenderBufffer);
            glRenderbufferStorage(GL_RENDERBUFFER, uDepthStencilFormat, (GLsizei)powW, (GLsizei)powH);
            glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_uDepthRenderBufffer);

            // if depth format is the one with stencil part, bind same render buffer as stencil attachment
            if (uDepthStencilFormat == GL_DEPTH24_STENCIL8)
            {
                glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_uDepthRenderBufffer);
            }
        }
//        // check if it worked (probably worth doing :) )
        CCAssert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Could not attach Image to framebuffer");

        ccGLBindTexture2D( m_uName );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );

        CAImageView* imageView = CAImageView::createWithFrame(CCRect(0, 0, m_uPixelsWide, m_uPixelsHigh));
        ccBlendFunc tBlendFunc = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA };
        imageView->setBlendFunc(tBlendFunc);
        this->addSubview(imageView);
        this->setImageView(imageView);
        
        glBindRenderbuffer(GL_RENDERBUFFER, oldRBO);
        glBindFramebuffer(GL_FRAMEBUFFER, m_nOldFBO);
        
        // Diabled by default.
        m_bAutoDraw = false;

        bRet = true;
    } while (0);
    
    CC_SAFE_FREE(data);
    
    return bRet;
}
开发者ID:Super-Man,项目名称:CrossApp,代码行数:87,代码来源:CARenderImage.cpp

示例14: atoi


//.........这里部分代码省略.........

				// speed
				modeA.speed = (float)atof(valueForKey("speed", dictionary));
				modeA.speedVar = (float)atof(valueForKey("speedVariance", dictionary));

                const char * pszTmp = NULL;
				// radial acceleration
                pszTmp = valueForKey("radialAcceleration", dictionary);
                modeA.radialAccel = (pszTmp) ? (float)atof(pszTmp) : 0;

                pszTmp = valueForKey("radialAccelVariance", dictionary);
				modeA.radialAccelVar = (pszTmp) ? (float)atof(pszTmp) : 0;

				// tangential acceleration
                pszTmp = valueForKey("tangentialAcceleration", dictionary);
				modeA.tangentialAccel = (pszTmp) ? (float)atof(pszTmp) : 0;

                pszTmp = valueForKey("tangentialAccelVariance", dictionary);
				modeA.tangentialAccelVar = (pszTmp) ? (float)atof(pszTmp) : 0;
			}

			// or Mode B: radius movement
			else if( m_nEmitterMode == kCCParticleModeRadius ) 
			{
				modeB.startRadius = (float)atof(valueForKey("maxRadius", dictionary));
				modeB.startRadiusVar = (float)atof(valueForKey("maxRadiusVariance", dictionary));
				modeB.endRadius = (float)atof(valueForKey("minRadius", dictionary));
				modeB.endRadiusVar = 0;
				modeB.rotatePerSecond = (float)atof(valueForKey("rotatePerSecond", dictionary));
				modeB.rotatePerSecondVar = (float)atof(valueForKey("rotatePerSecondVariance", dictionary));

			} else {
				CCAssert( false, "Invalid emitterType in config file");
				CC_BREAK_IF(true);
			}

			// life span
			m_fLife = (float)atof(valueForKey("particleLifespan", dictionary));
			m_fLifeVar = (float)atof(valueForKey("particleLifespanVariance", dictionary));

			// emission Rate
			m_fEmissionRate = m_uTotalParticles / m_fLife;

			// texture		
			// Try to get the texture from the cache
			char *textureName = (char *)valueForKey("textureFileName", dictionary);
            std::string fullpath = CCFileUtils::fullPathFromRelativeFile(textureName, m_sPlistFile.c_str());

			CCTexture2D *tex = NULL;

            if (strlen(textureName) > 0)
            {
                // set not pop-up message box when load image failed
                bool bNotify = CCFileUtils::getIsPopupNotify();
                CCFileUtils::setIsPopupNotify(false);
                tex = CCTextureCache::sharedTextureCache()->addImage(fullpath.c_str());

                // reset the value of UIImage notify
                CCFileUtils::setIsPopupNotify(bNotify);
            }

			if (tex)
			{
				this->m_pTexture = tex;
			}
			else
开发者ID:OrbotixInc,项目名称:cocos2d-x,代码行数:67,代码来源:CCParticleSystem.cpp

示例15: CCEGLView

bool AppDelegate::initInstance() {
	bool bRet = false;
	do {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)

		// Initialize OpenGLView instance, that release by CCDirector when application terminate.
		// The HelloWorld is designed as HVGA.
		CCEGLView * pMainWnd = new CCEGLView();
		CC_BREAK_IF(! pMainWnd
				|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 480, 320));

#endif  // CC_PLATFORM_WIN32
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

		// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.

#endif  // CC_PLATFORM_IOS
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)

		// OpenGLView initialized in HelloWorld/android/jni/helloworld/main.cpp
		// the default setting is to create a fullscreen view
		// if you want to use auto-scale, please enable view->create(320,480) in main.cpp
		// if the resources under '/sdcard" or other writeable path, set it.
		// warning: the audio source should in assets/
		// cocos2d::CCFileUtils::setResourcePath("/sdcard");

#endif  // CC_PLATFORM_ANDROID
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE)

		// Initialize OpenGLView instance, that release by CCDirector when application terminate.
		// The HelloWorld is designed as HVGA.
		CCEGLView* pMainWnd = new CCEGLView(this);
		CC_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480, WM_WINDOW_ROTATE_MODE_CW));

#ifndef _TRANZDA_VM_  
		// on wophone emulator, we copy resources files to Work7/NEWPLUS/TDA_DATA/Data/ folder instead of zip file
		cocos2d::CCFileUtils::setResource("HelloWorld.zip");
#endif

#endif  // CC_PLATFORM_WOPHONE
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
		// MaxAksenov said it's NOT a very elegant solution. I agree, haha
		CCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)

		// Initialize OpenGLView instance, that release by CCDirector when application terminate.
		// The HelloWorld is designed as HVGA.
		CCEGLView * pMainWnd = new CCEGLView();
		CC_BREAK_IF(! pMainWnd
				|| ! pMainWnd->Create("cocos2d: Hello World", 480, 320 ,480, 320));

		CCFileUtils::setResourcePath("../Resource/");

#endif  // CC_PLATFORM_LINUX

#if (CC_TARGET_PLATFORM == CC_PLATFORM_BADA)

		CCEGLView * pMainWnd = new CCEGLView();
		CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(this, 480, 320));
		pMainWnd->setDeviceOrientation(Osp::Ui::ORIENTATION_LANDSCAPE);
		CCFileUtils::setResourcePath("/Res/");

#endif  // CC_PLATFORM_BADA

#if (CC_TARGET_PLATFORM == CC_PLATFORM_QNX)
		CCEGLView * pMainWnd = new CCEGLView();
		CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(480, 320));
		CCFileUtils::setResourcePath("./app/native/Resource");
#endif // CC_PLATFORM_QNX

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WEBOS)
		
				// Initialize OpenGLView instance, that release by CCDirector when application terminate.
				// The HelloWorld is designed as HVGA.
				CCEGLView * pMainWnd = new CCEGLView();
				//Palm Touchpad resolution	
				CC_BREAK_IF(! pMainWnd
						|| ! pMainWnd->Create("cocos2d: Hello World", 1024, 768));
                // Palm Pre 3 resolution
				//CC_BREAK_IF(! pMainWnd
				//		|| ! pMainWnd->Create("cocos2d: Hello World", 480,800));	
				cocos2d::CCFileUtils::setResourcePath("./Res/");
	//			cocos2d::CCFileUtils::fullPathFromRelativePath("");
		
#endif  // CC_PLATFORM_WEBOS


		bRet = true;
	} while (0);
	return bRet;
}
开发者ID:Glikeme,项目名称:cocos2dx-webos,代码行数:92,代码来源:AppDelegate.cpp


注:本文中的CC_BREAK_IF函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。