cocos2dx使用版本︰v 2.0.4
cocosBuilder使用版本︰v 2.0 alpha 1
一、問題
今天在運行Xcode時,遇到了一個Xcode cannot run using the selected device.的錯誤。二、解決辦法
上網爬文,很多人都說是運行版本的設置不一致而產生該問題(見下圖)但筆者在實際實作時,
發現是因為擅自更改專案相關目錄名稱造成的問題。
如果以上辦法無法改善,
建議直接將整個專案砍掉重新建置了。
cocos2dx使用版本︰v 2.0.4
cocosBuilder使用版本︰v 2.0 alpha 1
cocos2dx使用版本︰v 2.0.4
cocosBuilder使用版本︰v 2.0 alpha 1
文章攢寫時間︰2012/12/29 12:53 cocos2dx使用版本︰v 2.0.4
cocosBuilder使用版本︰v 2.0 alpha 1
pushScene是舊的場景依然保留在內存,不釋放,所以沒問題,而replaceScene是要從內存裡釋放上一個場景里內容的,問題就出在當釋放內存時,場景要先刪除所有的child, 而當其中有一些child任然在運行著動作,導致刪除不成功,切換失敗。像你的labelClick就一直在執行動作。可以嘗試一下在切換場景之前運行[labelClick stopAllActions] 來試一下。
cocos2dx使用版本︰v 2.0.4
cocosBuilder使用版本︰v 2.0 alpha 1
在proj.android/jni/Android.mk中cocos2dx使用版本︰v 2.0.4
cocosBuilder使用版本︰v 2.0 alpha 1
攢寫時間︰2012/12/07 15:30cocos2dx使用版本︰v 2.0.4
cocosBuilder使用版本︰v 2.0 alpha 1
本文貼自JaoYE部落格 1 CCSize s = CCDirector::sharedDirector()->getWinSize(); 2 3 CCActionInterval* actionTo = CCMoveTo::create(2, CCPointMake(s.width-40, s.height-40)); //2s的时间移动到某个位置相对于屏幕 4 CCActionInterval* actionBy = CCMoveBy::create(2, CCPointMake(80,80)); //2s的时间移动到80,80 5 CCActionInterval* actionByBack = actionBy->reverse(); //让动作回复到actionBy之前的地方 6 7 m_tamara->runAction( actionTo); //执行actionTo 8 m_grossini->runAction( CCSequence::create(actionBy, actionByBack, NULL)); //顺序执行(actionBy,actionByBack),必须用NULL结尾 9 m_kathia->runAction(CCMoveTo::create(1, CCPointMake(40,40))); //1s的时间移动到40,40
1 CCActionInterval* actionTo = CCScaleTo::create(2.0f, 0.5f); //2个参数(时间,放大倍数) 2 CCActionInterval* actionBy = CCScaleBy::create(2.0f, 1.0f, 10.0f); //三个参数(时间,x方向放大倍数,y方向放大倍数) 3 CCActionInterval* actionBy2 = CCScaleBy::create(2.0f, 5.0f, 1.0f); 4 5 m_grossini->runAction( actionTo); 6 m_tamara->runAction( CCSequence::create(actionBy, actionBy->reverse(), NULL)); 7 m_kathia->runAction( CCSequence::create(actionBy2, actionBy2->reverse(), NULL));
1 CCActionInterval *actionTo = CCSkewTo::create(2, 37.2f, -37.2f); 2 CCActionInterval *actionToBack = CCSkewTo::create(2, 0, 0); 3 CCActionInterval *actionBy = CCSkewBy::create(2, 0.0f, -90.0f); 4 CCActionInterval *actionBy2 = CCSkewBy::create(2, 45.0f, 45.0f); 5 CCActionInterval *actionByBack = actionBy->reverse(); 6 7 m_tamara->runAction(CCSequence::create(actionTo, actionToBack, NULL)); 8 m_grossini->runAction(CCSequence::create(actionBy, actionByBack, NULL)); 9 10 m_kathia->runAction(CCSequence::create(actionBy2, actionBy2->reverse(), NULL));
1 CCActionInterval* actionTo = CCRotateTo::create( 2, 45); //2s内顺时针旋转45度(每跨度180,旋转方向会相反) 2 CCActionInterval* actionTo2 = CCRotateTo::create( 2, -45); //2s内逆时针旋转45度(每跨度180,旋转方向会相反) 3 CCActionInterval* actionTo0 = CCRotateTo::create(2 , 0); 4 m_tamara->runAction( CCSequence::create(actionTo, actionTo0, NULL)); 5 6 CCActionInterval* actionBy = CCRotateBy::create(2 , 360); //2s内自身旋转360度,正数为顺时针旋转,负数相反 7 CCActionInterval* actionByBack = actionBy->reverse(); //回复 8 m_grossini->runAction( CCSequence::create(actionBy, actionByBack, NULL)); 9 10 m_kathia->runAction( CCSequence::create(actionTo2, actionTo0->copy()->autorelease(), NULL)); 11 //actionTo0->copy()->autorelease() 不清楚 作用
1 CCActionInterval* actionTo = CCJumpTo::create(2, CCPointMake(300,300), 50, 4); //2s内跳向300,300的位置,跳跃高度为50,跳跃次数为4 2 CCActionInterval* actionBy = CCJumpBy::create(2, CCPointMake(300,0), 50, 4); //向x方向跳动300像素,跳跃高度为50,跳跃次数为4 3 CCActionInterval* actionUp = CCJumpBy::create(2, CCPointMake(0,0), 80, 4); //原地跳动 高度80 次数为4 4 CCActionInterval* actionByBack = actionBy->reverse(); //回复 5 6 m_tamara->runAction( actionTo); 7 m_grossini->runAction( CCSequence::create(actionBy, actionByBack, NULL)); //顺序执行actionBy, actionByBack动作 8 m_kathia->runAction( CCRepeatForever::create(actionUp)); //CCRepeatForever 一直重复相同的动作
1 CCMoveTo *moveTo = CCMoveTo::actionWithDuration(5, ccp(150,250)); 2 CCScaleTo *scaleTo = CCScaleTo::actionWithDuration(5, 3); 3 CCDelayTime *waiting = CCDelayTime::actionWithDuration(2);//停滞2秒 4 CCRotateBy *rotBy = CCRotateBy::actionWithDuration(5, 180); 5 //顺序执行定义好的动画 6 _sprite1->runAction(CCSequence::actions(moveTo,waiting,scaleTo,waiting,rotBy,NULL)); 7 //并发执行(同时执行)各类动画 8 _sprite2->runAction(CCSpawn::actions(moveTo,scaleTo,rotBy)); 9 //一直重复相同的动作 10 _sprite3->runAction(CCRepeatForever::actionWithAction(rotBy));
1 void ActionCallFunc::onEnter() 2 { 3 ActionsDemo::onEnter(); 4 5 centerSprites(3); 6 7 CCFiniteTimeAction* action = CCSequence::create( 8 CCMoveBy::create(2, CCPointMake(200,0)), 9 CCCallFunc::create(this, callfunc_selector(ActionCallFunc::callback1)), 10 NULL); 11 12 CCFiniteTimeAction* action2 = CCSequence::create( 13 CCScaleBy::create(2 , 2), 14 CCFadeOut::create(2), 15 CCCallFuncN::create(this, callfuncN_selector(ActionSequence2::callback2)), 16 NULL); 17 18 CCFiniteTimeAction* action3 = CCSequence::create( 19 CCRotateBy::create(3 , 360), 20 CCFadeOut::create(2), 21 CCCallFuncND::create(this, callfuncND_selector(ActionSequence2::callback3), (void*)0xbebabeba), 22 NULL); 23 24 m_grossini->runAction(action); 25 m_tamara->runAction(action2); 26 m_kathia->runAction(action3); 27 } 28 29 30 void ActionCallFunc::callback1() 31 { 32 CCSize s = CCDirector::sharedDirector()->getWinSize(); 33 CCLabelTTF *label = CCLabelTTF::create("callback 1 called", "Marker Felt", 16); 34 label->setPosition(CCPointMake( s.width/4*1,s.height/2)); 35 36 addChild(label); 37 } 38 39 void ActionCallFunc::callback2(CCNode* pSender) 40 { 41 CCSize s = CCDirector::sharedDirector()->getWinSize(); 42 CCLabelTTF *label = CCLabelTTF::create("callback 2 called", "Marker Felt", 16); 43 label->setPosition(CCPointMake( s.width/4*2,s.height/2)); 44 45 addChild(label); 46 } 47 48 void ActionCallFunc::callback3(CCNode* pTarget, void* data) 49 { 50 CCSize s = CCDirector::sharedDirector()->getWinSize(); 51 CCLabelTTF *label = CCLabelTTF::create("callback 3 called", "Marker Felt", 16); 52 label->setPosition(CCPointMake( s.width/4*3,s.height/2)); 53 addChild(label); 54 } 55
1 void ActionCallFuncND::onEnter() 2 { 3 ActionsDemo::onEnter(); 4 5 centerSprites(1); 6 7 CCFiniteTimeAction* action = CCSequence::create(CCMoveBy::create(2.0f, ccp(200,0)), 8 CCCallFuncND::create(this, callfuncND_selector(ActionCallFuncND::removeFromParentAndCleanup), (void*)true), 9 NULL); 10 11 m_grossini->runAction(action); 12 } 13 14 std::string ActionCallFuncND::title() 15 { 16 return "CallFuncND + auto remove"; 17 } 18 19 std::string ActionCallFuncND::subtitle() 20 { 21 return "CallFuncND + removeFromParentAndCleanup. Grossini dissapears in 2s"; 22 } 23 24 void ActionCallFuncND::removeFromParentAndCleanup(CCNode* pSender, void* data) 25 { 26 bool bCleanUp = (bool)data; 27 m_grossini->removeFromParentAndCleanup(bCleanUp); 28 }
cocos2dx使用版本︰v 2.0.4
cocosBuilder使用版本︰v 2.0 alpha 1
cocos2dx使用版本︰v 2.0.4
cocosBuilder使用版本︰v 2.0 alpha 1
cocos2dx在多解析度裡提供3種螢幕尺寸顯示方式︰cocos2dx使用版本︰v 2.0.4
cocosBuilder使用版本︰v 2.0 alpha 1
在RootViewController.mm裡,- (BOOL)shouldAutorotateToInterfaceOrientation:
函式的return值改回傳為return UIInterfaceOrientationIsPortrait( interfaceOrientation );
最後的樣子會變成︰
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsPortrait( interfaceOrientation ); }
cocos2dx使用版本︰v 2.0.4
cocosBuilder使用版本︰v 2.0 alpha 1
一、Problem cocos2dx使用版本︰v 2.0.4
cocosBuilder使用版本︰v 2.0 alpha 1
本站文章均为 李华明Himi 原创,转载务必在明显处注明:
1
2
3
4
5
| select the template version to install 3 for xcode3 4 for xcode4 input nothing for all 4 |
cocos2dx使用版本︰v2.0.4
cocosBuilder使用版本︰v2.0 alpha 1
CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache(); cache->addSpriteFramesWithFile("images2.plist"); CCArray *animFrame = new CCArray(4); CCSpriteFrame *frame = cache->spriteFrameByName("girl1.png"); // 加進第1幀 animFrame->addObject(frame); frame = cache->spriteFrameByName("girl2.png"); // 加進第2幀 animFrame->addObject(frame); frame = cache->spriteFrameByName("girl3.png"); // 加進第3幀 animFrame->addObject(frame); frame = cache->spriteFrameByName("girl4.png"); // 加進第4幀 animFrame->addObject(frame); CCAnimation* animation = new CCAnimation(); animation->initWithSpriteFrames(animFrame,0.1f); animation->autorelease(); ////创建动画 CCAnimate *animate = CCAnimate::actionWithAnimation(animation); CCSprite* pSprite1 = CCSprite::createWithSpriteFrameName("girl1.png"); pSprite1->setPosition(ccp(100,300)); pSprite1->runAction(CCRepeatForever::actionWithAction(animate)); this->addChild(pSprite1,0);另一種由影像載入的方式
CCTexture2D *pTexture=CCTextureCache::sharedTextureCache()->addImage("hero.png"); CCSpriteFrame *frame0=CCSpriteFrame::createWithTexture(pTexture,CCRectMake(0,0,32,32)); CCSpriteFrame *frame1=CCSpriteFrame::createWithTexture(pTexture,CCRectMake(32,0,32,32)); CCSpriteFrame *frame2=CCSpriteFrame::createWithTexture(pTexture,CCRectMake(64,0,32,32)); CCSpriteFrame *frame3=CCSpriteFrame::createWithTexture(pTexture,CCRectMake(96,0,32,32)); CCArray *animFrames=CCArray::create(); CC_BREAK_IF(!animFrames); animFrames->addObject(frame0); animFrames->addObject(frame1); animFrames->addObject(frame2); animFrames->addObject(frame3); CCAnimation *animation=CCAnimation::createWithSpriteFrames(animFrames,0.2f); CC_BREAK_IF(!animation); CCSprite *heroSprite0=CCSprite::createWithSpriteFrame(frame0); CC_BREAK_IF(!heroSprite0); heroSprite0->setPosition(ccp(100,100)); addChild(heroSprite0,1); CCAnimate *animate=CCAnimate::create(animation); heroSprite0->runAction(CCRepeatForever::create(animate));//一直执行下去