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


C++ CCSizeMake函数代码示例

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


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

示例1: getWinSize

bool SGBaseBox::init(SGBoxDelegate *dg, BoxTag bt, CCSize size, bool ishaveinfobg,bool isHaveBg,CCSize bottomsize,bool useDefaultBg)
{
    if (!SGBaseShow::init(NULL, bt, false))
    {
        return false;
    }


    ResourceManager::sharedInstance()->bindTexture("sgmainlayer/sgmainlayer.plist", RES_TYPE_LAYER_UI, sg_baseBox, LIM_PNG_AS_PNG);

    ResourceManager::sharedInstance()->bindTexture("sgsoldierslayer/sgsoldierslayer.plist", RES_TYPE_LAYER_UI, sg_baseBox, LIM_PNG_AS_PNG);

    ResourceManager::sharedInstance()->bindTexture("sgcountrylayer/sgcountrylayer.plist", RES_TYPE_LAYER_UI, sg_baseBox);


    CCSize s = CCDirector::sharedDirector() -> getWinSize();
    boxSize = size;
    deletage = dg;
    if (isHaveBg)
    {
        CCPoint center = ccpAdd(SGLayout::getPoint(kMiddleCenter), ccp(0, 0));
        CCSprite *bg1 = NULL;
        if (useDefaultBg)
        {
            biao=CCSprite::createWithSpriteFrameName("box_bian.png");
            this->addChild(biao, -1);
            biao->setPosition(ccpAdd(center, ccp(0, size.height*.5 -45)));

            ResourceManager::sharedInstance()->bindTexture("sanguobigpic/Tips.plist", RES_TYPE_LAYER_UI, sg_baseBox);

            cocos2d::extension::CCScale9Sprite *frame2 = cocos2d::extension::CCScale9Sprite::createWithSpriteFrameName("Tips.png");
            //cocos2d::extension::CCScale9Sprite *frame2 = cocos2d::extension::CCScale9Sprite::create("sanguobigpic/Tips.png");

            this->addChild(frame2,0);
            frame2->setScaleX(size.width/frame2->getContentSize().width);
            frame2->setScaleY(size.height/frame2->getContentSize().height);
            frame2->setPosition(ccpAdd(center, ccp(0,0)));


            CCLayerColor *bgLayer  =CCLayerColor::create(ccc4(0, 0, 0, 180), skewing(320)*3, skewingY(960)*3);
            this->addChild(bgLayer,-3);
            bgLayer->setPosition(ccpAdd(CCPointZero, ccp(-bgLayer->getContentSize().width*.5, -bgLayer->getContentSize().height*.5)));

        }
        else
        {
            ResourceManager::sharedInstance()->bindTexture("sanguobigpic/barrack_bg.plist", RES_TYPE_LAYER_UI, sg_baseBox);

            bg1 = CCSprite::createWithSpriteFrameName("barrack_bg.png");
            this->addChild(bg1 ,-2);

            bg1->setScaleY(s.height/bg1->getContentSize().height);
            bg1->setScaleX(s.width/bg1->getContentSize().width);
            bg1->setPosition(center);
        }

        if (ishaveinfobg)
        {
            ResourceManager::sharedInstance()->bindTexture("sanguobigpic/tipsinside.plist", RES_TYPE_LAYER_UI, sg_baseBox);

            fontbg = cocos2d::extension::CCScale9Sprite::createWithSpriteFrameName("tipsinside.png");
            this->addChild(fontbg,0);
            fontbg->setPreferredSize(CCSizeMake(size.width-55, size.height-162));//-112

            fontbg->setPosition(ccpAdd(center, ccp(0, 0)));//-27
        }


    }
    this->runactionwithscale();
    return true;
}
开发者ID:caoguoping,项目名称:warCraft,代码行数:72,代码来源:SGBaseBox.cpp

示例2: if

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
	CCSize frameSize = pEGLView->getFrameSize();

    pDirector->setOpenGLView(pEGLView);

    std::vector<std::string> searchPaths;

#if MC_ADAPTIVE_RESOLUTION == 1
    // Set the design resolution
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
    pEGLView->setDesignResolutionSize(PCResource.size.width, PCResource.size.height, kResolutionExactFit);
    searchPaths.push_back(PCResource.directory);
//    pDirector->setContentScaleFactor(MIN(32 * 25 / PCResource.size.width, 32 * 15 / PCResource.size.height));
//    pDirector->setContentScaleFactor(0.75f);
    pDirector->setContentScaleFactor(MIN(32 * 25 / frameSize.width, 32 * 15 / frameSize.height));
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
        // if the frame's height is larger than the height of medium resource size, select large resource.
	if (frameSize.height == smallResource.size.height) {
        pEGLView->setDesignResolutionSize(smallResource.size.width, smallResource.size.height, kResolutionNoBorder);
        searchPaths.push_back(smallResource.directory);
	}
        // if the frame's height is larger than the height of small resource size, select medium resource.
    else if (frameSize.height == mediumResource.size.height) {
        pEGLView->setDesignResolutionSize(mediumResource.size.width, mediumResource.size.height, kResolutionNoBorder);
        searchPaths.push_back(mediumResource.directory);
    }
        // if the frame's height is smaller than the height of medium resource size, select small resource.
	else {
        pEGLView->setDesignResolutionSize(largeResource.size.width, largeResource.size.height, kResolutionNoBorder);
		searchPaths.push_back(largeResource.directory);
    }
    pDirector->setContentScaleFactor(MIN(32 * 25 / frameSize.width, 32 * 15 / frameSize.height));
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    int i = 0;
    int size = sizeof(resources);
    int found = 0;
    for (; i < size; ++i) {
        if ((frameSize.width == resources[i].size.width && frameSize.height == resources[i].size.height)
            || (frameSize.width == resources[i].size.height && frameSize.height == resources[i].size.width)) {
            searchPaths.push_back(resources[i].directory);
            pEGLView->setDesignResolutionSize(resources[i].size.width, resources[i].size.height, kResolutionNoBorder);
            pDirector->setContentScaleFactor(MIN(32 * 25 / resources[i].size.width, 32 * 15 / resources[i].size.height));
            found = 1;
            break;
        }
    }
    if (found == 0) {
		searchPaths.push_back(resources[0].directory);
        pEGLView->setDesignResolutionSize(resources[0].size.width, resources[0].size.height, kResolutionNoBorder);
        pDirector->setContentScaleFactor(MIN(32 * 25 / resources[0].size.width, 32 * 15 / resources[0].size.height));
    }
#else
    // if the frame's height is larger than the height of medium resource size, select large resource.
	if (frameSize.height > mediumResource.size.height) {
        searchPaths.push_back(largeResource.directory);
        pEGLView->setDesignResolutionSize(largeResource.size.width, largeResource.size.height);
        pDirector->setContentScaleFactor(MIN(largeResource.size.height/smallResource.size.height, largeResource.size.width/smallResource.size.width));
	}
    // if the frame's height is larger than the height of small resource size, select medium resource.
    else if (frameSize.height > smallResource.size.height) {
        searchPaths.push_back(mediumResource.directory);
        pEGLView->setDesignResolutionSize(mediumResource.size.width, mediumResource.size.height);
        pDirector->setContentScaleFactor(MIN(mediumResource.size.height/smallResource.size.height, mediumResource.size.width/smallResource.size.width));
    }
    // if the frame's height is smaller than the height of medium resource size, select small resource.
	else {
		searchPaths.push_back(smallResource.directory);
        pEGLView->setDesignResolutionSize(smallResource.size.width, smallResource.size.height);
        pDirector->setContentScaleFactor(MIN(smallResource.size.height, smallResource.size.width));
    }
#endif // platforms
#else
    CCSize designSize = CCSizeMake(960, 640);
    
    searchPaths.push_back(CommonResource.directory);
    if (frameSize.height > 1280) {
        CCSize resourceSize = CCSizeMake(2048, 1536);
        std::vector<std::string> searchPaths;
//        searchPaths.push_back("hd"); //没资源
        pDirector->setContentScaleFactor(0.75 * resourceSize.height / designSize.height);
    } else {
        pDirector->setContentScaleFactor(0.75);
    }
    
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionFixedWidth);
#endif // MC_ADAPTIVE_RESOLUTION == 0
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
	
    // turn on display FPS
//    pDirector->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);
    
    CCLog("%s(%d): %.0f %.0f %.0f", __FILE__, __LINE__, frameSize.width, frameSize.height, pDirector->getContentScaleFactor());
    
    // register lua engine
//.........这里部分代码省略.........
开发者ID:edison9888,项目名称:__graduation_project,代码行数:101,代码来源:AppDelegate.cpp

示例3: sprintf

CCLayer* Tornado::getUnitCardDesc(int level,bool isAll) {
    CCLayer* layer = CCLayer::create();
    float attackLevelData = MyUtil::getInstance()->updateLevelByRate(0,baseDamage, level, updateDamageRate);
    float attackMaxData = MyUtil::getInstance()->updateLevelByRate(0,baseDamage, unitBean->getMaxLevel(), updateDamageRate);
    CCSprite* attackIcon = CCSprite::createWithSpriteFrameName("damageIcon.png");
    attackIcon->setPosition(ccp(40,360));
    layer->addChild(attackIcon);
    attackIcon->setScale(1.3);
    GXProgressBar* attackBar = GXProgressBar::create(CCSprite::create("levelBarUp.png"), CCSprite::create("BarDown.png"));
    
    attackBar->setContentSize(CCSizeMake(416,20));
    attackBar->updatePercentage((attackLevelData+baseDamage*unitBean->getMaxLevel())/(attackMaxData+baseDamage*unitBean->getMaxLevel()));
    attackBar->setPosition(ccp(70,337));
    
    
    char str[100] = {0};
    sprintf(str, "每秒造成伤害:%d",(int)(attackLevelData));
    
    CCLabelTTF* attackLabel = CCLabelTTF::create(str, "Arial", 28);
    attackLabel->setAnchorPoint(ccp(0,0));
    attackLabel->setColor(ccc3(238,204,122));
    attackLabel->setPosition(ccp(70,352));
    layer->addChild(attackBar);
    layer->addChild(attackLabel);
    
    //    CCLog("damageRate:%f",attackLevelData/attackMaxData);
    
    float speedLevelData = MyUtil::getInstance()->updateLevelByCount(baseSpeed, level, updateSpeedRate);
    
    float speedMaxData = MyUtil::getInstance()->updateLevelByCount(baseSpeed, unitBean->getMaxLevel(), updateSpeedRate);
    
    CCSprite* speedIcon = CCSprite::createWithSpriteFrameName("speedIcon.png");
    speedIcon->setScale(1.3);
    speedIcon->setPosition(ccp(40,300));
    layer->addChild(speedIcon);
    GXProgressBar* speedBar = GXProgressBar::create(CCSprite::create("levelBarUp.png"), CCSprite::create("BarDown.png"));
    
    speedBar->setContentSize(CCSizeMake(416,20));
    speedBar->updatePercentage(speedLevelData/speedMaxData);
    speedBar->setPosition(ccp(70,277));
    
    sprintf(str, "移动速度:%d",(int)(speedLevelData*10));
    
    CCLabelTTF* speedLabel = CCLabelTTF::create(str, "Arial", 24);
    speedLabel->setAnchorPoint(ccp(0,0));
    speedLabel->setColor(ccc3(238,204,122));
    speedLabel->setPosition(ccp(70,292));
    layer->addChild(speedBar);
    layer->addChild(speedLabel);
    
    //    CCLog("speedRate:%f",speedLevelData/speedMaxData);
    
    float healthLevelData = MyUtil::getInstance()->updateLevelByRate(0,baseHealth, level, updateHealthRate);
    float healthMaxData = MyUtil::getInstance()->updateLevelByRate(0,baseHealth, unitBean->getMaxLevel(),updateHealthRate);
    
    
    CCSprite* healthIcon = CCSprite::createWithSpriteFrameName("healthIcon.png");
    healthIcon->setScale(1.3);
    healthIcon->setPosition(ccp(40,240));
    layer->addChild(healthIcon);
    GXProgressBar* healthBar = GXProgressBar::create(CCSprite::create("levelBarUp.png"), CCSprite::create("BarDown.png"));
    
    healthBar->setContentSize(CCSizeMake(416,20));
    healthBar->updatePercentage((healthLevelData+baseHealth*unitBean->getMaxLevel())/(healthMaxData+baseHealth*unitBean->getMaxLevel()));
    
    healthBar->setPosition(ccp(70,217));
    
    sprintf(str, "耐久度:%d",(int)healthLevelData);
    
    CCLabelTTF* healthLabel = CCLabelTTF::create(str, "Arial", 24);
    healthLabel->setAnchorPoint(ccp(0,0));
    healthLabel->setColor(ccc3(238,204,122));
    healthLabel->setPosition(ccp(70,232));
    layer->addChild(healthBar);
    layer->addChild(healthLabel);
    
    //    CCLog("lifeRate:%f",healthLevelData/healthMaxData);
    
    float costLevelData = MyUtil::getInstance()->updateLevelByRate(0,baseCost, level, updateCostRate);
    float costMaxData = MyUtil::getInstance()->updateLevelByRate(0,baseCost, unitBean->getMaxLevel(), updateCostRate);
    
    CCSprite* costIcon = CCSprite::createWithSpriteFrameName("oilIcon.png");
    costIcon->setPosition(ccp(40,180));
    costIcon->setScale(40/costIcon->getContentSize().width);
    layer->addChild(costIcon);
    
    
    GXProgressBar* costBar = GXProgressBar::create(CCSprite::create("levelBarUp.png"), CCSprite::create("BarDown.png"));
    
    costBar->setContentSize(CCSizeMake(416,20));
    costBar->updatePercentage((costLevelData+baseCost*unitBean->getMaxLevel())/(costMaxData+baseCost*unitBean->getMaxLevel()));
    
    costBar->setPosition(ccp(70,157));
    
    
    sprintf(str, "派遣使用油料:%d",(int)(costLevelData));
    CCLabelTTF* costLabel = CCLabelTTF::create(str, "Arial", 24);
    costLabel->setAnchorPoint(ccp(0,0));
    costLabel->setColor(ccc3(238,204,122));
    costLabel->setPosition(ccp(70,172));
//.........这里部分代码省略.........
开发者ID:itita,项目名称:2-z-q-x-,代码行数:101,代码来源:Tornado.cpp

示例4: atoi

void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary<std::string, CCObject*> *dictionary, CCTexture2D *pobTexture)
{
	/*
	Supported Zwoptex Formats:

	ZWTCoordinatesFormatOptionXMLLegacy = 0, // Flash Version
	ZWTCoordinatesFormatOptionXML1_0 = 1, // Desktop Version 0.0 - 0.4b
	ZWTCoordinatesFormatOptionXML1_1 = 2, // Desktop Version 1.0.0 - 1.0.1
	ZWTCoordinatesFormatOptionXML1_2 = 3, // Desktop Version 1.0.2+
	*/

	CCDictionary<std::string, CCObject*> *metadataDict = (CCDictionary<std::string, CCObject*>*)dictionary->objectForKey(std::string("metadata"));
	CCDictionary<std::string, CCObject*> *framesDict = (CCDictionary<std::string, CCObject*>*)dictionary->objectForKey(std::string("frames"));
	int format = 0;

	// get the format
	if(metadataDict != NULL) 
	{
		format = atoi(valueForKey("format", metadataDict));
	}

	// check the format
	assert(format >=0 && format <= 3);

	framesDict->begin();
	std::string key = "";
	CCDictionary<std::string, CCObject*> *frameDict = NULL;
	while( frameDict = (CCDictionary<std::string, CCObject*>*)framesDict->next(&key) )
	{
		CCSpriteFrame *spriteFrame = m_pSpriteFrames->objectForKey(key);
		if (spriteFrame)
		{
			continue;
		}
		
		if(format == 0) 
		{
			float x = (float)atof(valueForKey("x", frameDict));
			float y = (float)atof(valueForKey("y", frameDict));
			float w = (float)atof(valueForKey("width", frameDict));
			float h = (float)atof(valueForKey("height", frameDict));
			float ox = (float)atof(valueForKey("offsetX", frameDict));
			float oy = (float)atof(valueForKey("offsetY", frameDict));
			int ow = atoi(valueForKey("originalWidth", frameDict));
			int oh = atoi(valueForKey("originalHeight", frameDict));
			// check ow/oh
			if(!ow || !oh)
			{
				CCLOG("cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist");
			}
			// abs ow/oh
			ow = abs(ow);
			oh = abs(oh);
			// create frame
			spriteFrame = new CCSpriteFrame();
			spriteFrame->initWithTexture(pobTexture, 
				                        CCRectMake(x, y, w, h), 
										false,
                                        CCPointMake(ox, oy),
                                        CCSizeMake((float)ow, (float)oh)
										);
		} 
		else if(format == 1 || format == 2) 
		{
			CCRect frame = CCRectFromString(valueForKey("frame", frameDict));
			bool rotated = false;

			// rotation
			if (format == 2)
			{
				rotated = atoi(valueForKey("rotated", frameDict)) == 0 ? false : true;
			}

			CCPoint offset = CCPointFromString(valueForKey("offset", frameDict));
			CCSize sourceSize = CCSizeFromString(valueForKey("sourceSize", frameDict));

			// create frame
			spriteFrame = new CCSpriteFrame();
			spriteFrame->initWithTexture(pobTexture, 
				frame,
				rotated,
				offset,
				sourceSize
				);
		} else
		if (format == 3)
		{
			/// @todo what's the format look like?
			assert(false);
			return;
			/*
			// get values
			CCSize spriteSize = CCSizeFromString(valueForKey("spriteSize", frameDict));
			CCPoint spriteOffset = CCPointFromString(valueForKey("spriteOffset", frameDict));
			CCSize spriteSourceSize = CCSizeFromString(valueForKey("spriteSourceSize", frameDict));
			CCRect textureRect = CCRectFromString(valueForKey("textureRect", frameDict));
			bool textureRotated = atoi(valueForKey("textureRotated", frameDict)) == 0;

			// get aliases
			CCArray<CCString*> *aliases = CCArray<CCString*>dictionary->objectForKey(std::string("aliases"));
//.........这里部分代码省略.........
开发者ID:BigHand,项目名称:cocos2d-x,代码行数:101,代码来源:CCSpriteFrameCache.cpp

示例5: glGetIntegerv

bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat)
{
    bool bRet = false;
    do 
    {
        w *= (int)CC_CONTENT_SCALE_FACTOR();
        h *= (int)CC_CONTENT_SCALE_FACTOR();

        glGetIntegerv(GL_FRAMEBUFFER_BINDING_OES, &m_nOldFBO);

        // textures must be power of two squared
        unsigned int powW = ccNextPOT(w);
        unsigned int powH = ccNextPOT(h);

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

        memset(data, 0, (int)(powW * powH * 4));
        m_ePixelFormat = eFormat;

        m_pTexture = new CCTexture2D();
        CC_BREAK_IF(! m_pTexture);

        m_pTexture->initWithData(data, (CCTexture2DPixelFormat)m_ePixelFormat, powW, powH, CCSizeMake((float)w, (float)h));
        free( data );

        // generate FBO
        ccglGenFramebuffers(1, &m_uFBO);
        ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_uFBO);

        // associate texture with FBO
        ccglFramebufferTexture2D(CC_GL_FRAMEBUFFER, CC_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_pTexture->getName(), 0);

        // check if it worked (probably worth doing :) )
        GLuint status = ccglCheckFramebufferStatus(CC_GL_FRAMEBUFFER);
        if (status != CC_GL_FRAMEBUFFER_COMPLETE)
        {
            CCAssert(0, "Render Texture : Could not attach texture to framebuffer");
            CC_SAFE_DELETE(m_pTexture);
            break;
        }

        m_pTexture->setAliasTexParameters();

        m_pSprite = CCSprite::spriteWithTexture(m_pTexture);

        m_pTexture->release();
        m_pSprite->setScaleY(-1);
        this->addChild(m_pSprite);

        ccBlendFunc tBlendFunc = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA };
        m_pSprite->setBlendFunc(tBlendFunc);

        ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_nOldFBO);
        bRet = true;
    } while (0);
    return bRet;
    
}
开发者ID:BigHand,项目名称:cocos2d-x,代码行数:59,代码来源:CCRenderTexture.cpp

示例6: CCSizeMake

bool CCSplitCols::initWithDuration(float duration, unsigned int nCols)
{
    m_nCols = nCols;
    return CCTiledGrid3DAction::initWithDuration(duration, CCSizeMake(nCols, 1));
}
开发者ID:solarzhong,项目名称:cocos2dx-classical,代码行数:5,代码来源:CCActionTiledGrid.cpp

示例7: CCSizeMake

//------------------------------------------------------------------------------
void LHJoint::createBox2dJointFromDictionary(LHDictionary* dictionary)
{
    joint = 0;
    
	if(NULL == dictionary)return;
	if(boxWorld == 0)return;
    
    
    LHSprite* sprA  = parentLoader->spriteWithUniqueName(dictionary->stringForKey("ObjectA"));
    b2Body* bodyA   = sprA->getBody();
	
    LHSprite* sprB  = parentLoader->spriteWithUniqueName(dictionary->stringForKey("ObjectB"));
    b2Body* bodyB   = sprB->getBody();
	
    CCPoint sprPosA = sprA->getPosition();
    CCPoint sprPosB = sprB->getPosition();
    
//    CCSize scaleA   = sprA->getRealScale();
//    CCSize scaleB   = sprB->getRealScale();
    
    CCSize scaleA   = CCSizeMake(sprA->getScaleX(), sprA->getScaleY());//[sprA realScale];
    CCSize scaleB   = CCSizeMake(sprB->getScaleX(), sprB->getScaleY());//[sprB realScale];
   
    scaleA = LHSettings::sharedInstance()->transformedSize(scaleA, sprA->getImageFile());
    scaleB = LHSettings::sharedInstance()->transformedSize(scaleB, sprB->getImageFile());
    
//    scaleA = [[LHSettings sharedInstance] transformedSize:scaleA forImage:[sprA imageFile]];
//    scaleB = [[LHSettings sharedInstance] transformedSize:scaleB forImage:[sprB imageFile]];
    
    
	if(NULL == bodyA || NULL == bodyB ) return;
	
	CCPoint anchorA = dictionary->pointForKey("AnchorA");
	CCPoint anchorB = dictionary->pointForKey("AnchorB");
    
	bool collideConnected = dictionary->boolForKey("CollideConnected");
	
    tag     = dictionary->intForKey("Tag");
    type    = (LH_JOINT_TYPE)dictionary->intForKey("Type");
    
	b2Vec2 posA, posB;
	
    float ptm = LHSettings::sharedInstance()->lhPtmRatio();
	float convertX = LHSettings::sharedInstance()->convertRatio().x;
	float convertY = LHSettings::sharedInstance()->convertRatio().y;
    
    if(!dictionary->boolForKey("CenterOfMass"))
    {        
        posA = b2Vec2((sprPosA.x + anchorA.x*scaleA.width)/ptm, 
                      (sprPosA.y - anchorA.y*scaleA.height)/ptm);
        
        posB = b2Vec2((sprPosB.x + anchorB.x*scaleB.width)/ptm, 
                      (sprPosB.y - anchorB.y*scaleB.height)/ptm);
        
    }
    else {		
        posA = bodyA->GetWorldCenter();
        posB = bodyB->GetWorldCenter();
    }
	
	if(0 != bodyA && 0 != bodyB)
	{
		switch ((int)type)
		{
			case LH_DISTANCE_JOINT:
			{
				b2DistanceJointDef jointDef;
				
				jointDef.Initialize(bodyA, 
									bodyB, 
									posA,
									posB);
				
				jointDef.collideConnected = collideConnected;
				
				jointDef.frequencyHz    = dictionary->floatForKey("Frequency");
				jointDef.dampingRatio   = dictionary->floatForKey("Damping");
				
				if(0 != boxWorld){
					joint = (b2DistanceJoint*)boxWorld->CreateJoint(&jointDef);
				}
			}	
				break;
				
			case LH_REVOLUTE_JOINT:
			{
				b2RevoluteJointDef jointDef;
				
				jointDef.lowerAngle     = CC_DEGREES_TO_RADIANS(dictionary->floatForKey("LowerAngle"));
				jointDef.upperAngle     = CC_DEGREES_TO_RADIANS(dictionary->floatForKey("UpperAngle"));
				jointDef.motorSpeed     = dictionary->floatForKey("MotorSpeed");
				jointDef.maxMotorTorque = dictionary->floatForKey("MaxTorque");
				jointDef.enableLimit    = dictionary->boolForKey("EnableLimit");
				jointDef.enableMotor    = dictionary->boolForKey("EnableMotor");
				jointDef.collideConnected = collideConnected;    
				
				jointDef.Initialize(bodyA, bodyB, posA);
				
				if(0 != boxWorld){
//.........这里部分代码省略.........
开发者ID:kdridi,项目名称:level-helper-sample,代码行数:101,代码来源:LHJoint.cpp

示例8: init

bool CCScrollView::init()
{
    return this->initWithViewSize(CCSizeMake(200, 200), NULL);
}
开发者ID:136446529,项目名称:book-code,代码行数:4,代码来源:CCScrollView.cpp

示例9: CCSizeMake

CCSize TextField::getTouchSize()
{
    return CCSizeMake(_touchWidth, _touchHeight);
}
开发者ID:237676098,项目名称:quick-cocos2d-x,代码行数:4,代码来源:UITextField.cpp

示例10: CCLOG

void GameStage::onEnter()
{
	CCLOG("gamestage onEnter");
	this->stageWidth = 640;
	this->stageHeight = 360;
	//监听失败消息
	CCNotificationCenter::sharedNotificationCenter()->addObserver(
		this,                         
		callfuncO_selector(GameStage::failCallBackFun),  // 处理的消息的回调函数
		FAIL,  // 感兴趣的消息名称
		NULL);   

	//背景
	ccColor4B color4b;
	color4b.r = 42;
	color4b.g = 43;
	color4b.b = 38;
	color4b.a = 0xFF;
	this->background = CCLayerColor::create(color4b);
	this->addChild(this->background);

	//运动背景
	float bgWidth = 43;
	float bgHeigth = this->stageHeight - 140;
	float gapH = 10;
	//使这个数组已经是当前类的成员变量,也必须要做一次retain
	this->drawBgList = CCArray::create();
	this->drawBgList->retain();

	ccColor4F color4f = ColorUtil::getColor4F(56, 57, 51, 255);

	CCDrawNode* drawNode = this->createMotionWall(0, 140, bgWidth, bgHeigth, gapH, color4f);
	float posX = drawNode->getContentSize().width;
	this->drawBgList->addObject(drawNode);
	this->addChild(drawNode);

	drawNode = this->createMotionWall(0, 140, bgWidth, bgHeigth, gapH, color4f);
	drawNode->setPosition(ccp(posX, 0));
	this->drawBgList->addObject(drawNode);
	this->addChild(drawNode);

	//地板
	color4b.r = 116;
	color4b.g = 115;
	color4b.b = 98;
	color4b.a = 0xFF;
	this->floorBg = CCLayerColor::create(color4b);

	CCSize size = CCSizeMake(this->stageWidth, 141);
	this->floorBg->setContentSize(size);
	this->addChild(this->floorBg);
	//地板线条
	color4b.r = 72;
	color4b.g = 66;
	color4b.b = 50;
	color4b.a = 0xFF;
	this->floorLineBg = CCLayerColor::create(color4b);
	size = CCSizeMake(this->stageWidth, 10);
	this->floorLineBg->setContentSize(size);
	this->addChild(this->floorLineBg);
	this->floorLineBg->setPosition(ccp(0, this->floorBg->getContentSize().height));

	//前景
	this->frontBgList = CCArray::create();
	this->frontBgList->retain();

	for (int i = 0; i < 3; i++)
	{
		drawNode = this->createFrontMotionWall(0, 83, this->stageWidth, this->stageHeight - 83, i);
		this->addChild(drawNode);
		drawNode->setPosition(ccp(this->stageWidth * (i - 1), 0));
		this->frontBgList->addObject(drawNode);
	}

	//初始化核心类
	this->pukaManCore = new PukaManCore();
	this->pukaManCore->initGame(17, 2, 10, 15, 0.3, 0, CCDirector::sharedDirector()->getWinSize().height - 35, 70);
	/*初始化人物*/
	this->initRole(this->pukaManCore->roleVo->x, this->pukaManCore->roleVo->y);

	this->uiLayer = CCLayer::create();
	this->uiText = CCSprite::create("uiText.png");
	this->uiText->setAnchorPoint(ccp(0, 0));
	this->uiText->setPosition(ccp(0, this->stageHeight - 50));
	this->uiLayer->addChild(this->uiText);
	this->addChild(this->uiLayer);

	this->bomb = NULL;
	this->comboList = NULL;
	this->scoreList = NULL;
	this->highScoreList = NULL;
	
	//设置最高分记录
	if(Cookie::isSaved())
		this->pukaManCore->highScore = Cookie::getShareUserData()->getIntegerForKey("highScore");

	//设置bombo数字
	this->updateCombo();
	this->updateScore();
	//设置最高分数数字
//.........这里部分代码省略.........
开发者ID:kanon1109,项目名称:Pukaman,代码行数:101,代码来源:GameStage.cpp

示例11: CCPoint

/*创建运动前景*/
CCDrawNode* GameStage::createFrontMotionWall(float x, float y, 
											 float bgWidth, float bgHeight, 
											 int tag)
{
	//前景列表
	CCDrawNode* drawNode = CCDrawNode::create();
	ccColor4F color = ColorUtil::getColor4F(141, 143, 129, 255);
	CCPoint points[] = {CCPoint(x, y), 
						CCPoint(x,  bgHeight + y), 
						CCPoint(x + bgWidth, bgHeight + y), 
						CCPoint(x + bgWidth, y)};
	//顶点列表,顶点数量,颜色
	drawNode->drawPolygon(points, 4, color, 0, ColorUtil::getColor4F(0, 0, 0, 0));

	//前景中段
	float my = y + 97;
	float mHeight = 93;
	color = ColorUtil::getColor4F(103, 107, 82, 255);
	CCPoint points2[] = {CCPoint(x, my), 
						 CCPoint(x,  mHeight + my), 
						 CCPoint(x + bgWidth, mHeight + my), 
						 CCPoint(x + bgWidth, my)};
	drawNode->drawPolygon(points2, 4, color, 0, ColorUtil::getColor4F(0, 0, 0, 0));
	
	mHeight = 3;
	my = my - mHeight;
	color = ColorUtil::getColor4F(86, 90, 67, 255);
	CCPoint points3[] = {CCPoint(x, my), 
						 CCPoint(x,  mHeight + my), 
						 CCPoint(x + bgWidth, mHeight + my), 
						 CCPoint(x + bgWidth, my)};
	drawNode->drawPolygon(points3, 4, color, 0, ColorUtil::getColor4F(0, 0, 0, 0));
	
	mHeight = 2;
	my = my - mHeight;
	color = ColorUtil::getColor4F(100, 103, 82, 255);
	CCPoint points4[] = {CCPoint(x, my), 
						 CCPoint(x,  mHeight + my), 
						 CCPoint(x + bgWidth, mHeight + my), 
						 CCPoint(x + bgWidth, my)};
	drawNode->drawPolygon(points4, 4, color, 0, ColorUtil::getColor4F(0, 0, 0, 0));

	mHeight = 1;
	my = my - mHeight;
	color = ColorUtil::getColor4F(113, 116, 99, 255);
	CCPoint points5[] = {CCPoint(x, my), 
		CCPoint(x,  mHeight + my), 
		CCPoint(x + bgWidth, mHeight + my), 
		CCPoint(x + bgWidth, my)};
	drawNode->drawPolygon(points5, 4, color, 0, ColorUtil::getColor4F(0, 0, 0, 0));
	drawNode->setAnchorPoint(ccp(0, 0));
	drawNode->setContentSize(CCSizeMake(bgWidth, bgHeight));

	//创建阴影 设置注册点在top和center
	CCSprite* shadow = CCSprite::create("shadow.png");
	shadow->setTag(tag);
	shadow->setAnchorPoint(ccp(.5, 1));
	shadow->setPosition(ccp(shadow->getContentSize().width *.5, y));
	drawNode->setTag(tag);
	drawNode->addChild(shadow);
	return drawNode;
}
开发者ID:kanon1109,项目名称:Pukaman,代码行数:63,代码来源:GameStage.cpp

示例12: CCAssert

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

    bool bRet = false;
    void *data = NULL;
    do 
    {
        w = (int)(w * CC_CONTENT_SCALE_FACTOR());
        h = (int)(h * CC_CONTENT_SCALE_FACTOR());

        glGetIntegerv(GL_FRAMEBUFFER_BINDING, &m_nOldFBO);

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

        if (CCConfiguration::sharedConfiguration()->supportsNPOT())
        {
            powW = w;
            powH = h;
        }
        else
        {
            powW = ccNextPOT(w);
            powH = ccNextPOT(h);
        }

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

        memset(data, 0, (int)(powW * powH * 4));
        m_ePixelFormat = eFormat;

        m_pTexture = new CCTexture2D();
        if (m_pTexture)
        {
            m_pTexture->initWithData(data, (CCTexture2DPixelFormat)m_ePixelFormat, powW, powH, CCSizeMake((float)w, (float)h));
        }
        else
        {
            break;
        }
        GLint oldRBO;
        glGetIntegerv(GL_RENDERBUFFER_BINDING, &oldRBO);
        
        if (CCConfiguration::sharedConfiguration()->checkForGLExtension("GL_QCOM"))
        {
            m_pTextureCopy = new CCTexture2D();
            if (m_pTextureCopy)
            {
                m_pTextureCopy->initWithData(data, (CCTexture2DPixelFormat)m_ePixelFormat, powW, powH, CCSizeMake((float)w, (float)h));
            }
            else
            {
                break;
            }
        }

        // generate FBO
        glGenFramebuffers(1, &m_uFBO);
        glBindFramebuffer(GL_FRAMEBUFFER, m_uFBO);

        // associate texture with FBO
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_pTexture->getName(), 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 texture to framebuffer");

        m_pTexture->setAliasTexParameters();

        // retained
        setSprite(CCSprite::createWithTexture(m_pTexture));

        m_pTexture->release();
        m_pSprite->setScaleY(-1);

        ccBlendFunc tBlendFunc = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA };
        m_pSprite->setBlendFunc(tBlendFunc);

        glBindRenderbuffer(GL_RENDERBUFFER, oldRBO);
        glBindFramebuffer(GL_FRAMEBUFFER, m_nOldFBO);
        
        // Diabled by default.
        m_bAutoDraw = false;
//.........这里部分代码省略.........
开发者ID:cheerayhuang,项目名称:cocos2d-x,代码行数:101,代码来源:CCRenderTexture.cpp

示例13: CCSizeMake

bool AppDelegate::applicationDidFinishLaunching() {
	// initialize director
	    CCDirector *pDirector = CCDirector::sharedDirector();

	    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());

	    CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
	    CCSize designSize = CCSizeMake(480, 320);
	    std::vector<std::string> searchPaths;

	    if (screenSize.height > 320)
	    {
	        searchPaths.push_back("hd");
	        searchPaths.push_back("sd");
	        pDirector->setContentScaleFactor(640.0f/designSize.height);
	    }
	    else
	    {
	        searchPaths.push_back("sd");
	        pDirector->setContentScaleFactor(320.0f/designSize.height);
	    }

	    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);

	    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionExactFit);

	    // turn on display FPS
	    pDirector->setDisplayStats(true);

	    // set FPS. the default value is 1.0/60 if you don't call this
	    pDirector->setAnimationInterval(1.0 / 60);

	    // create a scene. it's an autorelease object
	    CCScene *pScene = HelloWorld::scene();

	    // run
	    pDirector->runWithScene(pScene);

	    return true;
//	// initialize director
//	CCDirector* pDirector = CCDirector::sharedDirector();
//	CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
//
//	pDirector->setOpenGLView(pEGLView);
//	CCSize visibleSize = pDirector->getVisibleSize();
//	// Set the design resolution
//	pEGLView->setDesignResolutionSize(visibleSize.width,
//			visibleSize.height, kResolutionShowAll);
//	CCSize frameSize = pEGLView->getFrameSize();
//	cocos2d::CCLog("frameSize.width=%2f, frameSize.height=%2f",frameSize.width, frameSize.height);
//
////	float ratio = frameSize.width / frameSize.height;
////	float ratio1 = largeDesignResolutionSize.width / largeDesignResolutionSize.height;
////	float ratio2 = mediumDesignResolutionSize.width / mediumDesignResolutionSize.height;
////	float ratio3 = smallDesignResolutionSize.width / smallDesignResolutionSize.height;
////	float d1 = abs(ratio - ratio1);
////	float d2 = abs(ratio - ratio2);
////	float d3 = abs(ratio - ratio3);
////	std::map<float, CCSize> designSize;
////	designSize[d1] = largeDesignResolutionSize;
////	designSize[d2] = mediumDesignResolutionSize;
////	designSize[d3] = smallDesignResolutionSize;
////	std::map<float, CCSize>::reverse_iterator iter = designSize.rbegin();
//
//	//得到key最大的,因此我这里是横屏,所以以高度为基准,为了确保缩放后宽度能全屏,所以选取宽高比最大的为设计方案
////	CCSize designResolutionSize = iter->second;
//
//	//pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);
////	pEGLView->setDesignResolutionSize(designResolutionSize.width,
////			designResolutionSize.height, kResolutionShowAll);
//
//	//pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionExactFit);
//
////	if (frameSize.height > mediumResource.size.height) {
////		CCFileUtils::sharedFileUtils()->setResourceDirectory(
////				largeResource.directory);
////		pDirector->setContentScaleFactor(
////				largeResource.size.height / designResolutionSize.height);
////	} else if (frameSize.height > smallResource.size.height) {
////		CCFileUtils::sharedFileUtils()->setResourceDirectory(
////				mediumResource.directory);
////		pDirector->setContentScaleFactor(
////				mediumResource.size.height / designResolutionSize.height);
////	} else {
////		CCFileUtils::sharedFileUtils()->setResourceDirectory(
////				smallResource.directory);
////		pDirector->setContentScaleFactor(
////				smallResource.size.height / designResolutionSize.height);
////	}
//
//	std::vector<std::string> searchPath;
//
//	// In this demo, we select resource according to the frame's height.
//	// If the resource size is different from design resolution size, you need to set contentScaleFactor.
//	// We use the ratio of resource's height to the height of design resolution,
//	// this can make sure that the resource's height could fit for the height of design resolution.
//
//	// if the frame's height is larger than the height of medium resource size, select large resource.
//	if (frameSize.height > mediumResource.size.height) {
//		searchPath.push_back(largeResource.directory);
//.........这里部分代码省略.........
开发者ID:yohyow,项目名称:cocos2dxTest,代码行数:101,代码来源:AppDelegate.cpp

示例14: CCSizeMake

bool RPGDialogLayer::init(string titleStr, string menuOKStr, int menuItemOKTag, string menuCancelStr, int menuItemCancelTag, float width, float height, CCObject* target, SEL_MenuHandler seletor)
{
    if(CCLayerColor::initWithColor(ccc4(0, 0, 0, 200), width, height))
    {
        this->initCommons(titleStr);
        
        CCTMXTiledMap *mainBg = (CCTMXTiledMap*)this->getChildByTag(kRPGDialogLayerBg);
        CCMenu *menu = (CCMenu*)mainBg->getChildByTag(kRPGDialogLayerBgMenu);
        
        CCLabelTTF *menuOKLab = CCLabelTTF::create(OzgCCUtility::generalString(CCString::create(menuOKStr)->getCString()).c_str(), "Arial", 20, CCSizeMake(120, 25), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
        menuOKLab->setColor(ccc3(160, 160, 160));
        CCMenuItemLabel *menuOK = CCMenuItemLabel::create(menuOKLab, target, seletor);
        menuOK->setTag(menuItemOKTag);
        menuOK->setPosition(ccp(100, 60));
        menu->addChild(menuOK);
        
        CCLabelTTF *menuCancelLab = CCLabelTTF::create(OzgCCUtility::generalString(CCString::create(menuCancelStr)->getCString()).c_str(), "Arial", 20, CCSizeMake(120, 25), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
        menuCancelLab->setColor(ccc3(160, 160, 160));
        CCMenuItemLabel *menuCancel = CCMenuItemLabel::create(menuCancelLab, target, seletor);
        menuCancel->setTag(menuItemCancelTag);
        menuCancel->setPosition(ccp(280, 60));
        menu->addChild(menuCancel);
        
        return true;
    }
    
    return false;
}
开发者ID:aboduo,项目名称:OzgGameRPG,代码行数:28,代码来源:RPGDialogLayer.cpp

示例15: CCSizeMake

void CCEGLViewProtocol::setFrameSize(float width, float height)
{
    m_obDesignResolutionSize = m_obScreenSize = CCSizeMake(width, height);
}
开发者ID:vedi,项目名称:cocos2d-x,代码行数:4,代码来源:CCEGLViewProtocol.cpp


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