├── 1.png ├── 2.png ├── README.md └── popstart ├── Classes ├── AppDelegate.cpp ├── AppDelegate.h ├── GameLevel.cpp ├── GameLevel.h ├── GameScene.cpp ├── GameScene.h ├── PopStar.cpp ├── PopStar.h ├── PopStarDataMgr.cpp ├── PopStarDataMgr.h ├── PopStarLayer.cpp ├── PopStarLayer.h ├── PopStarState.cpp ├── PopStarState.h ├── Star.cpp ├── Star.h ├── StartLayer.cpp └── StartLayer.h ├── Resources ├── CloseNormal.png ├── CloseSelected.png ├── HelloWorld.png ├── Thumbs.db ├── buttons │ ├── .svn │ │ ├── all-wcprops │ │ ├── entries │ │ └── format │ └── default │ │ ├── .svn │ │ ├── all-wcprops │ │ ├── entries │ │ ├── format │ │ ├── prop-base │ │ │ ├── 00010.png.svn-base │ │ │ └── Thumbs.db.svn-base │ │ └── text-base │ │ │ ├── 00010.png.svn-base │ │ │ └── Thumbs.db.svn-base │ │ ├── 00010.png │ │ └── Thumbs.db ├── fonts │ ├── .svn │ │ ├── all-wcprops │ │ ├── entries │ │ ├── format │ │ ├── prop-base │ │ │ ├── Marker Felt.ttf.svn-base │ │ │ └── arial.ttf.svn-base │ │ └── text-base │ │ │ ├── Marker Felt.ttf.svn-base │ │ │ └── arial.ttf.svn-base │ ├── Marker Felt.ttf │ └── arial.ttf ├── popstar_bg.png ├── popstar_start.png └── stars │ ├── .svn │ ├── all-wcprops │ ├── entries │ ├── format │ ├── prop-base │ │ ├── Thumbs.db.svn-base │ │ ├── blue.png.svn-base │ │ ├── green.png.svn-base │ │ ├── purple.png.svn-base │ │ ├── red.png.svn-base │ │ └── yellow.png.svn-base │ └── text-base │ │ ├── Thumbs.db.svn-base │ │ ├── blue.png.svn-base │ │ ├── green.png.svn-base │ │ ├── purple.png.svn-base │ │ ├── red.png.svn-base │ │ └── yellow.png.svn-base │ ├── Thumbs.db │ ├── blue.png │ ├── green.png │ ├── purple.png │ ├── red.png │ └── yellow.png ├── proj.android ├── .classpath ├── .cproject ├── .project ├── AndroidManifest.xml ├── README.md ├── ant.properties ├── build.xml ├── build_native.sh ├── jni │ ├── Android.mk │ ├── Application.mk │ └── hellocpp │ │ └── main.cpp ├── proguard-project.txt ├── project.properties ├── res │ ├── drawable-hdpi │ │ └── icon.png │ ├── drawable-ldpi │ │ └── icon.png │ ├── drawable-mdpi │ │ └── icon.png │ └── values │ │ └── strings.xml └── src │ └── com │ └── MyCompany │ └── popstart │ └── popstart.java ├── proj.ios ├── AppController.h ├── AppController.mm ├── Default-568h@2x.png ├── Default.png ├── Default@2x.png ├── Icon-114.png ├── Icon-120.png ├── Icon-144.png ├── Icon-152.png ├── Icon-57.png ├── Icon-72.png ├── Icon-76.png ├── Info.plist ├── Prefix.pch ├── RootViewController.h ├── RootViewController.mm ├── main.m └── popstart.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── zeroyang.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── zeroyang.xcuserdatad │ └── xcschemes │ ├── popstart.xcscheme │ └── xcschememanagement.plist ├── proj.linux ├── .cproject ├── .project ├── Makefile ├── build.sh └── main.cpp ├── proj.mac ├── AppController.h ├── AppController.mm ├── Icon.icns ├── Info.plist ├── Prefix.pch ├── en.lproj │ ├── InfoPlist.strings │ └── MainMenu.xib ├── main.m └── popstart.xcodeproj │ └── project.pbxproj ├── proj.win32 ├── main.cpp ├── main.h ├── popstart.sln ├── popstart.vcxproj ├── popstart.vcxproj.filters └── popstart.vcxproj.user ├── proj.wp8-xaml ├── popstart.sln └── popstart │ ├── popstart │ ├── App.xaml │ ├── App.xaml.cs │ ├── Assets │ │ ├── AlignmentGrid.png │ │ ├── ApplicationIcon.png │ │ └── Tiles │ │ │ ├── FlipCycleTileLarge.png │ │ │ ├── FlipCycleTileMedium.png │ │ │ ├── FlipCycleTileSmall.png │ │ │ ├── IconicTileMediumLarge.png │ │ │ └── IconicTileSmall.png │ ├── EditBox.xaml │ ├── EditBox.xaml.cs │ ├── LocalizedStrings.cs │ ├── MainPage.xaml │ ├── MainPage.xaml.cs │ ├── Properties │ │ ├── AppManifest.xml │ │ ├── AssemblyInfo.cs │ │ └── WMAppManifest.xml │ ├── Resources │ │ ├── AppResources.Designer.cs │ │ └── AppResources.resx │ ├── SplashScreenImage.jpg │ ├── popstart.csproj │ └── popstart.csproj.user │ └── popstartComponent │ ├── pch.cpp │ ├── pch.h │ ├── popstartComponent.vcxproj │ └── popstartComponent.vcxproj.filters └── proj.wp8 ├── Assets ├── AlignmentGrid.png ├── ApplicationIcon.png └── Tiles │ ├── FlipCycleTileLarge.png │ ├── FlipCycleTileMedium.png │ ├── FlipCycleTileSmall.png │ ├── IconicTileMediumLarge.png │ └── IconicTileSmall.png ├── WMAppManifest.xml ├── pch.cpp ├── pch.h ├── popstart.cpp ├── popstart.h ├── popstart.sln ├── popstart.vcxproj └── popstart.vcxproj.filters /1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/1.png -------------------------------------------------------------------------------- /2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/2.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PopStar 2 | Cocos2d-x v2.2 PopStar Game 3 | 4 | 5 | --- 6 | 7 | 8 | #Cocos2d-x 开发《消灭星星》游戏 9 | 10 | 用Cocos2d-x开发跨平台游戏,高仿《消灭星星》游戏。 11 | ——和传统的消除类游戏不同,本游戏没有时间限制,只要两个相同颜色的星星就可以消除,以关卡的形式进行游戏,每个关卡的分数需求累计增加。 12 | 13 | ##开发环境 14 | * Cocos2d-x v2.2 15 | * Mac + Xcode (下载项目,拷贝到Cocos2d-x v2.2下的projects目录,proj.ios可以直接打开编译运行) 16 | * 其他平台自己编辑资源和源码引用 17 | 18 | ## 游戏截图 19 | ![](./1.png) 20 | 21 | ![](./2.png) 22 | 23 | -------------------------------------------------------------------------------- /popstart/Classes/AppDelegate.cpp: -------------------------------------------------------------------------------- 1 | #include "AppDelegate.h" 2 | //#include "HelloWorldScene.h" 3 | #include "StartLayer.h" 4 | 5 | USING_NS_CC; 6 | 7 | AppDelegate::AppDelegate() { 8 | 9 | } 10 | 11 | AppDelegate::~AppDelegate() 12 | { 13 | } 14 | 15 | bool AppDelegate::applicationDidFinishLaunching() { 16 | // initialize director 17 | CCDirector* pDirector = CCDirector::sharedDirector(); 18 | CCEGLView* pEGLView = CCEGLView::sharedOpenGLView(); 19 | 20 | pDirector->setOpenGLView(pEGLView); 21 | 22 | //pEGLView->setDesignResolutionSize(320, 480, kResolutionShowAll); 23 | 24 | // turn on display FPS 25 | pDirector->setDisplayStats(false); 26 | 27 | // set FPS. the default value is 1.0/60 if you don't call this 28 | pDirector->setAnimationInterval(1.0 / 60); 29 | 30 | // create a scene. it's an autorelease object 31 | //CCScene *pScene = HelloWorld::scene(); 32 | CCScene* pScene = StartLayer::scene(); 33 | 34 | // run 35 | pDirector->runWithScene(pScene); 36 | 37 | return true; 38 | } 39 | 40 | // This function will be called when the app is inactive. When comes a phone call,it's be invoked too 41 | void AppDelegate::applicationDidEnterBackground() { 42 | CCDirector::sharedDirector()->stopAnimation(); 43 | 44 | // if you use SimpleAudioEngine, it must be pause 45 | // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); 46 | } 47 | 48 | // this function will be called when the app is active again 49 | void AppDelegate::applicationWillEnterForeground() { 50 | CCDirector::sharedDirector()->startAnimation(); 51 | 52 | // if you use SimpleAudioEngine, it must resume here 53 | // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); 54 | } 55 | -------------------------------------------------------------------------------- /popstart/Classes/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #ifndef _APP_DELEGATE_H_ 2 | #define _APP_DELEGATE_H_ 3 | 4 | #include "cocos2d.h" 5 | 6 | /** 7 | @brief The cocos2d Application. 8 | 9 | The reason for implement as private inheritance is to hide some interface call by CCDirector. 10 | */ 11 | class AppDelegate : private cocos2d::CCApplication 12 | { 13 | public: 14 | AppDelegate(); 15 | virtual ~AppDelegate(); 16 | 17 | /** 18 | @brief Implement CCDirector and CCScene init code here. 19 | @return true Initialize success, app continue. 20 | @return false Initialize failed, app terminate. 21 | */ 22 | virtual bool applicationDidFinishLaunching(); 23 | 24 | /** 25 | @brief The function be called when the application enter background 26 | @param the pointer of the application 27 | */ 28 | virtual void applicationDidEnterBackground(); 29 | 30 | /** 31 | @brief The function be called when the application enter foreground 32 | @param the pointer of the application 33 | */ 34 | virtual void applicationWillEnterForeground(); 35 | }; 36 | 37 | #endif // _APP_DELEGATE_H_ 38 | 39 | -------------------------------------------------------------------------------- /popstart/Classes/GameLevel.cpp: -------------------------------------------------------------------------------- 1 | #include "PopStarLayer.h" 2 | #include "PopStarDataMgr.h" 3 | #include "GameScene.h" 4 | 5 | #include "GameLevel.h" 6 | 7 | USING_NS_CC; 8 | 9 | 10 | // on "init" you need to initialize your instance 11 | bool GameLevel::init() 12 | { 13 | ////////////////////////////// 14 | // 1. super init first 15 | if ( !CCLayer::init() ) 16 | { 17 | return false; 18 | } 19 | 20 | CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); 21 | CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); 22 | 23 | char szData[32] = {0}; 24 | int level = getPopStarDataMgr().getLevel(); 25 | int score = getPopStarDataMgr().getTargetScoreByLevel(level); 26 | snprintf(szData, 32, "Level:%d", level); 27 | labelLevel = CCLabelTTF::create(szData, "Arial", 24); 28 | 29 | labelLevel->setPosition(ccp(origin.x + visibleSize.width/2 + 250, 30 | origin.y + visibleSize.height - labelLevel->getContentSize().height - 50)); 31 | 32 | this->addChild(labelLevel, 1); 33 | 34 | snprintf(szData, 32, "Target Score:%d", score); 35 | labelTargetScore = CCLabelTTF::create(szData, "Arial", 24); 36 | 37 | labelTargetScore->setPosition(ccp(origin.x + visibleSize.width/2 + 500, 38 | origin.y + visibleSize.height - labelTargetScore->getContentSize().height - 150)); 39 | 40 | this->addChild(labelTargetScore, 1); 41 | 42 | this->schedule(schedule_selector(GameLevel::onTimeUp), 4); 43 | 44 | CCPoint pos1 = labelLevel->getPosition(); 45 | CCMoveTo* move1 = CCMoveTo::create( 1, ccp(pos1.x-250, pos1.y) ); 46 | labelLevel->runAction(move1); 47 | 48 | CCPoint pos2 = labelTargetScore->getPosition(); 49 | CCMoveTo* move2 = CCMoveTo::create( 2, ccp(pos2.x-500, pos2.y) ); 50 | labelTargetScore->runAction(move2); 51 | 52 | return true; 53 | } 54 | 55 | void GameLevel::onTimeUp(float delta) 56 | { 57 | changeLayer( this, PopStarLayer::create() ); 58 | } 59 | -------------------------------------------------------------------------------- /popstart/Classes/GameLevel.h: -------------------------------------------------------------------------------- 1 | #ifndef __GAME_LEVEL_H__ 2 | #define __GAME_LEVEL_H__ 3 | 4 | #include "cocos2d.h" 5 | 6 | class GameLevel : public cocos2d::CCLayer 7 | { 8 | public: 9 | // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone 10 | virtual bool init(); 11 | 12 | //static cocos2d::CCScene* scene(); 13 | 14 | // implement the "static node()" method manually 15 | CREATE_FUNC(GameLevel); 16 | 17 | void onTimeUp(float delta); 18 | 19 | //void onClickMenu(cocos2d::CCObject* obj); 20 | 21 | private: 22 | cocos2d::CCLabelTTF* labelLevel; 23 | cocos2d::CCLabelTTF* labelTargetScore; 24 | }; 25 | 26 | #endif // __GAME_LEVEL_H__ 27 | -------------------------------------------------------------------------------- /popstart/Classes/GameScene.cpp: -------------------------------------------------------------------------------- 1 | #include "StartLayer.h" 2 | 3 | #include "GameScene.h" 4 | 5 | USING_NS_CC; 6 | 7 | CCScene* createScene() 8 | { 9 | // 'scene' is an autorelease object 10 | CCScene *scene = CCScene::create(); 11 | 12 | // 'layer' is an autorelease object 13 | StartLayer *layer = StartLayer::create(); 14 | 15 | // add layer as a child to scene 16 | scene->addChild(layer); 17 | 18 | // return the scene 19 | return scene; 20 | } 21 | 22 | void changeLayer(CCLayer* curLayer, CCLayer* newLayer) 23 | { 24 | if (!curLayer || !newLayer) 25 | { 26 | return; 27 | } 28 | 29 | CCScene* scene = CCDirector::sharedDirector()->getRunningScene(); 30 | if (scene) 31 | { 32 | scene->removeChild(curLayer); 33 | scene->addChild(newLayer); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /popstart/Classes/GameScene.h: -------------------------------------------------------------------------------- 1 | #ifndef __GAME_SCENE_H__ 2 | #define __GAME_SCENE_H__ 3 | 4 | #include "cocos2d.h" 5 | 6 | cocos2d::CCScene* createScene(); 7 | void changeLayer(cocos2d::CCLayer* curLayer, cocos2d::CCLayer* newLayer); 8 | 9 | 10 | #endif // __GAME_SCENE_H__ 11 | -------------------------------------------------------------------------------- /popstart/Classes/PopStar.h: -------------------------------------------------------------------------------- 1 | #ifndef __POPSTAR_H__ 2 | #define __POPSTAR_H__ 3 | 4 | #include "cocos2d.h" 5 | 6 | class PopStarLayer; 7 | class Star; 8 | 9 | struct SelectStar 10 | { 11 | int row; 12 | int col; 13 | Star* star; 14 | }; 15 | 16 | class PopStarState; 17 | 18 | class PopStar : public cocos2d::CCNode 19 | { 20 | enum 21 | { 22 | ROW_NUM = 10, // 行数 23 | COL_NUM = 10, // 列数 24 | 25 | REVERSE_NUM = 100, // 预留允许最大数 26 | }; 27 | 28 | typedef std::list StarList; 29 | typedef StarList::iterator StarListIter; 30 | 31 | public: 32 | PopStar(PopStarLayer* layer); 33 | virtual ~PopStar(); 34 | 35 | static PopStar* create(PopStarLayer* layer); 36 | bool init(); 37 | 38 | void onClick(const cocos2d::CCPoint& pos); 39 | void onUpdate(float delta); 40 | 41 | void setScore(int score); // 设置当前分数 42 | void setLevel(int level); 43 | void setHistoryScore(int score); 44 | void setHistoryLevelScore(int score); 45 | void setTargetScore(int score); 46 | 47 | bool isLevelEnd(); // 本关是否结束 48 | bool isGameOver(); // 游戏是否结束 49 | 50 | void changeState(PopStarState* newState); 51 | bool isInitFinish(); // 是否初始化完成 52 | 53 | int getLeftStarNum(); // 获取剩余的星星数 54 | void clearStarsOneByOne(); 55 | void gotoNextLevel(); // 跳到下一关 56 | void gotoStartLayer(); // 返回到开始 57 | 58 | private: 59 | void onReduce(); 60 | void onSelect(const SelectStar& selectStar); 61 | void clearSelectStars(); 62 | bool isNeedHoriAdjust(); // 是否需要水平调整 63 | int getCheckEndCol(); // 获取需要水平调整的最大列数 64 | 65 | private: 66 | PopStarLayer* gameLayer; 67 | Star* stars[ROW_NUM][COL_NUM]; 68 | StarList selectStars; 69 | 70 | PopStarState* currentState; 71 | float elapsedTime; 72 | }; 73 | 74 | #endif // __POPSTAR_H__ -------------------------------------------------------------------------------- /popstart/Classes/PopStarDataMgr.cpp: -------------------------------------------------------------------------------- 1 | #include "Star.h" 2 | 3 | #include "PopStarDataMgr.h" 4 | 5 | USING_NS_CC; 6 | 7 | namespace 8 | { 9 | const int MAX_REDUCE_STAR_NUM = 30; 10 | int REDUCENUM_SCORE_MAP[MAX_REDUCE_STAR_NUM][2] = 11 | { 12 | {2, 20}, 13 | {3, 45}, 14 | {4, 80}, 15 | {5, 125}, 16 | {6, 180}, 17 | {7, 245}, 18 | {8, 320}, 19 | {9, 405}, 20 | {10, 500}, 21 | {11, 605}, 22 | {12, 720}, 23 | {13, 845}, 24 | {14, 980}, 25 | {15, 1125}, 26 | {16, 1280}, 27 | {17, 1445}, 28 | {18, 1620}, 29 | {19, 1805}, 30 | {20, 2000}, 31 | {21, 2205}, 32 | {22, 2420}, 33 | {23, 2645}, 34 | {24, 2880}, 35 | {25, 3125}, 36 | {26, 3380}, 37 | {27, 3645}, 38 | {28, 3920}, 39 | {29, 4205}, 40 | {30, 4500}, 41 | {31, 4805} 42 | }; 43 | const int MAX_LEFT_STAR_NUM = 10; 44 | const int LEFTNUM_SCORE_MAP[MAX_LEFT_STAR_NUM][2] = 45 | { 46 | {0, 2000}, 47 | {1, 1980}, 48 | {2, 1920}, 49 | {3, 1820}, 50 | {4, 1680}, 51 | {5, 1500}, 52 | {6, 1280}, 53 | {7, 1020}, 54 | {8, 720}, 55 | {9, 380} 56 | }; 57 | 58 | const std::string HISTORY_TOTAL_SCORE = std::string("historyTotalScore"); // 历史最高分 59 | const std::string HISTORY_MAX_LEVEL = std::string("historyMaxLevel"); // 历史最高到达关数 60 | const std::string HISTORY_LEVEL_SCORE = std::string("historyLevelScore%d"); // 历史每关到达最高分数 61 | } 62 | 63 | PopStarDataMgr::PopStarDataMgr() 64 | { 65 | gameLevel = 1; 66 | curScore = 0; 67 | 68 | historyScore = CCUserDefault::sharedUserDefault()->getIntegerForKey(HISTORY_TOTAL_SCORE.c_str(), 0); 69 | 70 | int historyMaxLevel = CCUserDefault::sharedUserDefault()->getIntegerForKey(HISTORY_MAX_LEVEL.c_str(), 1); 71 | for (int i = 0; i < historyMaxLevel; ++i) 72 | { 73 | char szBuf[64] = {0}; 74 | snprintf(szBuf, 64, HISTORY_LEVEL_SCORE.c_str(), i+1); 75 | int score = CCUserDefault::sharedUserDefault()->getIntegerForKey(szBuf, 0); 76 | historyLevelScores.push_back(score); 77 | } 78 | 79 | init(); 80 | } 81 | 82 | PopStarDataMgr::~PopStarDataMgr() 83 | { 84 | } 85 | 86 | bool PopStarDataMgr::init() 87 | { 88 | reduceNumScoreMap.clear(); 89 | for (int i = 0; i < MAX_REDUCE_STAR_NUM; ++i) 90 | { 91 | reduceNumScoreMap.insert( std::make_pair(REDUCENUM_SCORE_MAP[i][0], REDUCENUM_SCORE_MAP[i][1]) ); 92 | } 93 | 94 | leftNumScoreMap.clear(); 95 | for (int i = 0; i < MAX_LEFT_STAR_NUM; ++i) 96 | { 97 | leftNumScoreMap.insert( std::make_pair(LEFTNUM_SCORE_MAP[i][0], LEFTNUM_SCORE_MAP[i][1]) ); 98 | } 99 | 100 | return true; 101 | } 102 | 103 | int PopStarDataMgr::getScore() 104 | { 105 | return curScore; 106 | } 107 | 108 | void PopStarDataMgr::setScore(int score) 109 | { 110 | curScore = score; 111 | } 112 | 113 | int PopStarDataMgr::getLevel() 114 | { 115 | return gameLevel; 116 | } 117 | 118 | void PopStarDataMgr::setLevel(int level) 119 | { 120 | gameLevel = level; 121 | } 122 | 123 | int PopStarDataMgr::getHistoryScore() 124 | { 125 | return historyScore; 126 | } 127 | 128 | void PopStarDataMgr::setHistoryScore(int score) 129 | { 130 | if (score > historyScore) 131 | { 132 | historyScore = score; 133 | CCUserDefault::sharedUserDefault()->setIntegerForKey(HISTORY_TOTAL_SCORE.c_str(), score); 134 | CCUserDefault::sharedUserDefault()->setIntegerForKey(HISTORY_MAX_LEVEL.c_str(), gameLevel); 135 | CCUserDefault::sharedUserDefault()->flush(); 136 | } 137 | } 138 | 139 | int PopStarDataMgr::getHistoryLevelScoreByLevel(int level) 140 | { 141 | int score = 0; 142 | if (level <= (int)historyLevelScores.size()) 143 | { 144 | score = historyLevelScores[level-1]; 145 | } 146 | 147 | return score; 148 | } 149 | 150 | void PopStarDataMgr::setHistoryLevelScore(int level, int score) 151 | { 152 | char szBuf[64] = {0}; 153 | snprintf(szBuf, 64, HISTORY_LEVEL_SCORE.c_str(), level); 154 | if (level <= (int)historyLevelScores.size()) 155 | { 156 | historyLevelScores[level-1] = score; 157 | CCUserDefault::sharedUserDefault()->setIntegerForKey(szBuf, score); 158 | CCUserDefault::sharedUserDefault()->flush(); 159 | } 160 | else if (level == (historyLevelScores.size()+1)) 161 | { 162 | historyLevelScores.push_back(score); 163 | CCUserDefault::sharedUserDefault()->setIntegerForKey(szBuf, score); 164 | CCUserDefault::sharedUserDefault()->flush(); 165 | } 166 | else 167 | { 168 | CCLog("setHistoryLevelScoreByLevel error, level=%d score=%d", level, score); 169 | } 170 | } 171 | 172 | int PopStarDataMgr::getScoreByReduceNum(int num) 173 | { 174 | int score = 0; 175 | 176 | std::map::iterator iter = reduceNumScoreMap.find(num); 177 | if (iter == reduceNumScoreMap.end()) 178 | { 179 | if (num < 2) 180 | { 181 | return 0; 182 | } 183 | else if (num > MAX_REDUCE_STAR_NUM) 184 | { 185 | return 1000000; 186 | } 187 | } 188 | else 189 | { 190 | score = iter->second; 191 | } 192 | 193 | return score; 194 | } 195 | 196 | int PopStarDataMgr::getScoreByLeftNum(int num) 197 | { 198 | int score = 0; 199 | std::map::iterator iter = leftNumScoreMap.find(num); 200 | if (iter != leftNumScoreMap.end()) 201 | { 202 | score = iter->second; 203 | } 204 | 205 | return score; 206 | } 207 | 208 | int PopStarDataMgr::getTargetScoreByLevel(int level) 209 | { 210 | int score = 0; 211 | if (level == 1) 212 | { 213 | score = 1000; 214 | } 215 | else if (level == 2) 216 | { 217 | score = 3000; 218 | } 219 | else if ( (level >=3) && (level <= 10) ) 220 | { 221 | score = 3000 + 3000 * (level - 2); 222 | } 223 | else 224 | { 225 | score = 27000 + 4000 * (level - 10); 226 | } 227 | 228 | return score; 229 | } 230 | 231 | PopStarDataMgr& getPopStarDataMgr() 232 | { 233 | static PopStarDataMgr mgr; 234 | return mgr; 235 | } -------------------------------------------------------------------------------- /popstart/Classes/PopStarDataMgr.h: -------------------------------------------------------------------------------- 1 | #ifndef __POPSTAR_DATA_MGR_H__ 2 | #define __POPSTAR_DATA_MGR_H__ 3 | 4 | class PopStarDataMgr 5 | { 6 | public: 7 | PopStarDataMgr(); 8 | ~PopStarDataMgr(); 9 | 10 | bool init(); 11 | 12 | int getScore(); 13 | void setScore(int score); // 设置当前分数 14 | 15 | int getLevel(); 16 | void setLevel(int level); 17 | 18 | int getHistoryScore(); 19 | void setHistoryScore(int score); 20 | 21 | int getHistoryLevelScoreByLevel(int level); 22 | void setHistoryLevelScore(int level, int score); 23 | 24 | int getScoreByReduceNum(int num); // 根据消除星星数获取得到分数 25 | int getScoreByLeftNum(int num); // 根据剩余星星数获取得到分数 26 | int getTargetScoreByLevel(int level); // 根据关卡获取目标分数 27 | 28 | private: 29 | std::map reduceNumScoreMap; 30 | std::map leftNumScoreMap; 31 | 32 | int curScore; 33 | int gameLevel; 34 | int historyScore; // 历史最高分 35 | 36 | std::vector historyLevelScores; 37 | }; 38 | 39 | PopStarDataMgr& getPopStarDataMgr(); 40 | 41 | #endif // __POPSTAR_DATA_MGR_H__ -------------------------------------------------------------------------------- /popstart/Classes/PopStarLayer.cpp: -------------------------------------------------------------------------------- 1 | #include "PopStar.h" 2 | #include "../extensions/CocoStudio/gui/UIWidgets/UILabel.h" 3 | 4 | #include "PopStarLayer.h" 5 | 6 | USING_NS_CC; 7 | 8 | PopStarLayer::~PopStarLayer() 9 | { 10 | if (popStar) 11 | { 12 | delete popStar; 13 | popStar = NULL; 14 | } 15 | } 16 | 17 | // on "init" you need to initialize your instance 18 | bool PopStarLayer::init() 19 | { 20 | ////////////////////////////// 21 | // 1. super init first 22 | if ( !CCLayer::init() ) 23 | { 24 | return false; 25 | } 26 | 27 | CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); 28 | CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); 29 | 30 | srand( (unsigned)time( NULL ) ); 31 | 32 | float scale = visibleSize.width/320.f; 33 | CCSprite* popStarBg = CCSprite::create("popstar_bg.png"); 34 | popStarBg->setPosition(ccp(160*scale, 400*scale)); 35 | popStarBg->setScale(scale); 36 | this->addChild(popStarBg, 0); 37 | 38 | historyTotalScore = CCLabelTTF::create("0", "Arial", 24); 39 | if (historyTotalScore) 40 | { 41 | historyTotalScore->setPosition(ccp(160*scale, 464*scale)); 42 | this->addChild(historyTotalScore); 43 | } 44 | 45 | historyLevelScore = CCLabelTTF::create("0", "Arial", 24); 46 | if (historyLevelScore) 47 | { 48 | historyLevelScore->setPosition(ccp(160*scale, 437*scale)); 49 | this->addChild(historyLevelScore); 50 | } 51 | 52 | gameLevel = CCLabelTTF::create("0", "Arial", 24); 53 | if (gameLevel) 54 | { 55 | gameLevel->setPosition(ccp(80*scale, 405*scale)); 56 | this->addChild(gameLevel); 57 | } 58 | 59 | targetScore = CCLabelTTF::create("0", "Arial", 24); 60 | if (targetScore) 61 | { 62 | targetScore->setPosition(ccp(230*scale, 405*scale)); 63 | this->addChild(targetScore); 64 | } 65 | 66 | curScore = CCLabelTTF::create("0", "Arial", 24); 67 | if (curScore) 68 | { 69 | curScore->setPosition(ccp(80*scale, 378*scale)); 70 | this->addChild(curScore); 71 | } 72 | 73 | reduceScore = CCLabelTTF::create("", "Arial", 24); 74 | if (reduceScore) 75 | { 76 | reduceScore->setPosition(ccp(120*scale, 340*scale)); 77 | reduceScore->setHorizontalAlignment(kCCTextAlignmentLeft); 78 | this->addChild(reduceScore); 79 | } 80 | 81 | popStar = new PopStar(this); 82 | 83 | this->schedule(schedule_selector(PopStarLayer::update)); 84 | 85 | return true; 86 | } 87 | 88 | void PopStarLayer::onEnter() 89 | { 90 | CCLayer::onEnter(); 91 | 92 | this->setTouchEnabled(true); 93 | } 94 | 95 | void PopStarLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) 96 | { 97 | CCTouch* touch = (CCTouch*)pTouches->anyObject(); 98 | CCPoint locInView = touch->getLocationInView(); 99 | CCPoint loc = CCDirector::sharedDirector()->convertToGL(locInView); 100 | 101 | if (popStar) 102 | { 103 | popStar->onClick(loc); 104 | } 105 | 106 | } 107 | 108 | void PopStarLayer::update(float delta) 109 | { 110 | if (!popStar) 111 | { 112 | return; 113 | } 114 | 115 | popStar->onUpdate(delta); 116 | } 117 | 118 | void PopStarLayer::onGuiEvent(GUI_EVENT_TYPE event, int nValue, unsigned int uValue) 119 | { 120 | switch (event) 121 | { 122 | case EVENT_UPDATE_SCORE: 123 | { 124 | if (curScore) 125 | { 126 | char szBuf[32] = {0}; 127 | //itoa(nValue, szBuf, 10); 128 | sprintf(szBuf, "%d", nValue); 129 | curScore->setString(szBuf); 130 | } 131 | } 132 | break; 133 | case EVENT_UPDATE_TARGET_SCORE: 134 | { 135 | if (targetScore) 136 | { 137 | char szBuf[32] = {0}; 138 | //itoa(nValue, szBuf, 10); 139 | sprintf(szBuf, "%d", nValue); 140 | targetScore->setString(szBuf); 141 | } 142 | } 143 | break; 144 | case EVENT_UPDATE_LEVEL: 145 | { 146 | if (gameLevel) 147 | { 148 | char szBuf[32] = {0}; 149 | //itoa(nValue, szBuf, 10); 150 | sprintf(szBuf, "%d", nValue); 151 | gameLevel->setString(szBuf); 152 | } 153 | } 154 | break; 155 | case EVENT_UPDATE_REDUCE_SCORE: 156 | { 157 | if (reduceScore) 158 | { 159 | if (nValue == 0) 160 | { 161 | reduceScore->setString(""); 162 | } 163 | else 164 | { 165 | char szBuf[32] = {0}; 166 | snprintf(szBuf, 32, "Number: %d Score: %u", nValue, uValue); 167 | reduceScore->setString(szBuf); 168 | } 169 | } 170 | } 171 | break; 172 | case EVENT_UPDATE_TOTAL_HISTORY_SCORE: 173 | { 174 | if (historyTotalScore) 175 | { 176 | char szBuf[32] = {0}; 177 | snprintf(szBuf, 32, "%d", nValue); 178 | historyTotalScore->setString(szBuf); 179 | } 180 | } 181 | break; 182 | case EVENT_UPDATE_LEVEL_HISTORY_SCORE: 183 | { 184 | if (historyLevelScore) 185 | { 186 | char szBuf[32] = {0}; 187 | snprintf(szBuf, 32, "%d", nValue); 188 | historyLevelScore->setString(szBuf); 189 | } 190 | } 191 | break; 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /popstart/Classes/PopStarLayer.h: -------------------------------------------------------------------------------- 1 | #ifndef __HELLOWORLD_SCENE_H__ 2 | #define __HELLOWORLD_SCENE_H__ 3 | 4 | #include "cocos2d.h" 5 | 6 | class PopStar; 7 | 8 | enum GUI_EVENT_TYPE 9 | { 10 | EVENT_UPDATE_SCORE, // 刷新分数 11 | EVENT_UPDATE_TARGET_SCORE, // 刷新目标分数 12 | EVENT_UPDATE_LEVEL, // 刷新关卡 13 | EVENT_UPDATE_REDUCE_SCORE, // 刷新消除分数 14 | EVENT_UPDATE_TOTAL_HISTORY_SCORE, // 刷新历史最高分 15 | EVENT_UPDATE_LEVEL_HISTORY_SCORE, // 刷新本关最高分 16 | }; 17 | 18 | class PopStarLayer : public cocos2d::CCLayer 19 | { 20 | public: 21 | ~PopStarLayer(); 22 | 23 | // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone 24 | virtual bool init(); 25 | 26 | virtual void onEnter(); 27 | virtual void ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent); 28 | 29 | void update(float delta); 30 | 31 | void onGuiEvent(GUI_EVENT_TYPE event, int nValue, unsigned int uValue = 0); 32 | 33 | // implement the "static node()" method manually 34 | CREATE_FUNC(PopStarLayer); 35 | 36 | 37 | public: 38 | cocos2d::CCLabelTTF* historyTotalScore; // 历史最高分 39 | cocos2d::CCLabelTTF* historyLevelScore; // 本关最高分 40 | cocos2d::CCLabelTTF* gameLevel; // 关卡 41 | cocos2d::CCLabelTTF* targetScore; // 目标 42 | cocos2d::CCLabelTTF* curScore; // 分数 43 | cocos2d::CCLabelTTF* reduceScore; 44 | 45 | private: 46 | PopStar* popStar; 47 | }; 48 | 49 | #endif // __HELLOWORLD_SCENE_H__ -------------------------------------------------------------------------------- /popstart/Classes/PopStarState.cpp: -------------------------------------------------------------------------------- 1 | #include "PopStar.h" 2 | 3 | #include "PopStarState.h" 4 | 5 | USING_NS_CC; 6 | 7 | namespace 8 | { 9 | const float REDUCE_INTERVAL_TIME = 0.3f; 10 | } 11 | 12 | PopStarState::PopStarState(PopStar* ps) 13 | { 14 | popStar = ps; 15 | elapsedTime = 0.f; 16 | } 17 | 18 | PopStarState::~PopStarState() 19 | { 20 | popStar = NULL; 21 | } 22 | 23 | GameInitState::GameInitState(PopStar* ps) : PopStarState(ps) 24 | { 25 | state = POPSTAR_STATE_INIT; 26 | } 27 | 28 | void GameInitState::enter() 29 | { 30 | 31 | } 32 | 33 | void GameInitState::execute(float delta) 34 | { 35 | if (popStar && popStar->isInitFinish()) 36 | { 37 | popStar->changeState( new GameRunningState(popStar) ); 38 | } 39 | } 40 | 41 | void GameInitState::exit() 42 | { 43 | 44 | } 45 | 46 | GameRunningState::GameRunningState(PopStar* ps) : PopStarState(ps) 47 | { 48 | state = POPSTAR_STATE_NORMAL; 49 | } 50 | 51 | void GameRunningState::enter() 52 | { 53 | 54 | } 55 | 56 | void GameRunningState::execute(float delta) 57 | { 58 | 59 | } 60 | 61 | void GameRunningState::exit() 62 | { 63 | 64 | } 65 | 66 | GamePassLevelState::GamePassLevelState(PopStar* ps) : PopStarState(ps) 67 | { 68 | state = POPSTAR_STATE_PASS; 69 | } 70 | 71 | void GamePassLevelState::enter() 72 | { 73 | 74 | } 75 | 76 | void GamePassLevelState::execute(float delta) 77 | { 78 | if (!popStar) 79 | { 80 | return; 81 | } 82 | 83 | elapsedTime += delta; 84 | if (elapsedTime >= REDUCE_INTERVAL_TIME) 85 | { 86 | elapsedTime -= REDUCE_INTERVAL_TIME; 87 | popStar->clearStarsOneByOne(); 88 | 89 | int num = popStar->getLeftStarNum(); 90 | if (num == 0) 91 | { 92 | popStar->gotoNextLevel(); 93 | } 94 | } 95 | } 96 | 97 | void GamePassLevelState::exit() 98 | { 99 | 100 | } 101 | 102 | GameOverState::GameOverState(PopStar* ps) : PopStarState(ps) 103 | { 104 | state = POPSTAR_STATE_OVER; 105 | } 106 | 107 | void GameOverState::enter() 108 | { 109 | 110 | } 111 | 112 | void GameOverState::execute(float delta) 113 | { 114 | if (!popStar) 115 | { 116 | return; 117 | } 118 | 119 | elapsedTime += delta; 120 | if (elapsedTime >= REDUCE_INTERVAL_TIME) 121 | { 122 | elapsedTime -= REDUCE_INTERVAL_TIME; 123 | popStar->clearStarsOneByOne(); 124 | 125 | int num = popStar->getLeftStarNum(); 126 | if (num == 0) 127 | { 128 | popStar->gotoStartLayer(); 129 | } 130 | } 131 | } 132 | 133 | void GameOverState::exit() 134 | { 135 | 136 | } 137 | -------------------------------------------------------------------------------- /popstart/Classes/PopStarState.h: -------------------------------------------------------------------------------- 1 | #ifndef __POPSTAR_STATE_H__ 2 | #define __POPSTAR_STATE_H__ 3 | 4 | #include "cocos2d.h" 5 | 6 | enum POPSTAR_STATE 7 | { 8 | POPSTAR_STATE_INIT, // 初始化状态 9 | POPSTAR_STATE_NORMAL, // 正常状态 10 | POPSTAR_STATE_PASS, // 过关状态 11 | POPSTAR_STATE_OVER, // 未过关状态 12 | }; 13 | 14 | class PopStar; 15 | 16 | // PopStar状态基类 17 | class PopStarState 18 | { 19 | public: 20 | PopStarState(PopStar* ps); 21 | virtual ~PopStarState(); 22 | 23 | virtual void enter() = 0; // 当状态被进入时执行这个 24 | virtual void execute(float delta) = 0; // 状态正常更新 25 | virtual void exit() = 0; // 当状态退出时执行这个 26 | 27 | protected: 28 | POPSTAR_STATE state; 29 | PopStar* popStar; 30 | float elapsedTime; 31 | }; 32 | 33 | // 游戏初始化状态 34 | class GameInitState : public PopStarState 35 | { 36 | public: 37 | GameInitState(PopStar* ps); 38 | 39 | virtual void enter(); 40 | virtual void execute(float delta); 41 | virtual void exit(); 42 | }; 43 | 44 | // 正常游戏状态 45 | class GameRunningState : public PopStarState 46 | { 47 | public: 48 | GameRunningState(PopStar* ps); 49 | 50 | virtual void enter(); 51 | virtual void execute(float delta); 52 | virtual void exit(); 53 | }; 54 | 55 | class GamePassLevelState : public PopStarState 56 | { 57 | public: 58 | GamePassLevelState(PopStar* ps); 59 | 60 | virtual void enter(); 61 | virtual void execute(float delta); 62 | virtual void exit(); 63 | }; 64 | 65 | class GameOverState : public PopStarState 66 | { 67 | public: 68 | GameOverState(PopStar* ps); 69 | 70 | virtual void enter(); 71 | virtual void execute(float delta); 72 | virtual void exit(); 73 | }; 74 | 75 | #endif // __POPSTAR_STATE_H__ -------------------------------------------------------------------------------- /popstart/Classes/Star.cpp: -------------------------------------------------------------------------------- 1 | #include "Star.h" 2 | 3 | USING_NS_CC; 4 | 5 | namespace 6 | { 7 | const int MAX_STAR_NUM = 5; 8 | const float MOVE_SPEED = 300.0f; 9 | const std::string STAR_PATH[MAX_STAR_NUM] = 10 | { 11 | std::string("stars/red.png"), 12 | std::string("stars/yellow.png"), 13 | std::string("stars/green.png"), 14 | std::string("stars/blue.png"), 15 | std::string("stars/purple.png"), 16 | }; 17 | 18 | void Clamp(int& val, int min, int max) 19 | { 20 | if (val < min) 21 | { 22 | val = min; 23 | } 24 | else if (val > max) 25 | { 26 | val = max; 27 | } 28 | } 29 | } 30 | 31 | Star::Star(int index) 32 | { 33 | this->index = index; 34 | Clamp(this->index, 1, MAX_STAR_NUM); 35 | highlight = false; 36 | 37 | init(); 38 | } 39 | 40 | Star* Star::create(int index) 41 | { 42 | Star* pRet = new Star(index); 43 | std::string path = pRet->getPath(); 44 | if (pRet && pRet->initWithFile(path.c_str())) 45 | { 46 | pRet->autorelease(); 47 | } 48 | else 49 | { 50 | CC_SAFE_DELETE(pRet); 51 | } 52 | 53 | return pRet; 54 | } 55 | 56 | bool Star::isHighLight() 57 | { 58 | return highlight; 59 | } 60 | 61 | void Star::setHighLight(bool hl) 62 | { 63 | highlight = hl; 64 | } 65 | 66 | int Star::getIndex() 67 | { 68 | return index; 69 | } 70 | 71 | void Star::setPos(const cocos2d::CCPoint& pos) 72 | { 73 | CCSprite::setPosition(pos); 74 | 75 | destPos = pos; 76 | } 77 | 78 | cocos2d::CCPoint Star::getDestPos() 79 | { 80 | return destPos; 81 | } 82 | 83 | void Star::setDestPos(const cocos2d::CCPoint& pos) 84 | { 85 | destPos = pos; 86 | } 87 | 88 | bool Star::init() 89 | { 90 | if (!CCSprite::init()) 91 | { 92 | return false; 93 | } 94 | 95 | return true; 96 | } 97 | 98 | void Star::draw(void) 99 | { 100 | CC_PROFILER_START_CATEGORY(kCCProfilerCategorySprite, "CCSprite - draw"); 101 | 102 | CCAssert(!m_pobBatchNode, "If CCSprite is being rendered by CCSpriteBatchNode, CCSprite#draw SHOULD NOT be called"); 103 | 104 | CC_NODE_DRAW_SETUP(); 105 | 106 | if (highlight) 107 | { 108 | ccGLBlendFunc(GL_SRC_COLOR, GL_ONE); 109 | } 110 | else 111 | { 112 | ccGLBlendFunc( m_sBlendFunc.src, m_sBlendFunc.dst ); 113 | } 114 | 115 | 116 | ccGLBindTexture2D( m_pobTexture->getName() ); 117 | ccGLEnableVertexAttribs( kCCVertexAttribFlag_PosColorTex ); 118 | 119 | 120 | 121 | #define kQuadSize sizeof(m_sQuad.bl) 122 | #ifdef EMSCRIPTEN 123 | long offset = 0; 124 | setGLBufferData(&m_sQuad, 4 * kQuadSize, 0); 125 | #else 126 | long offset = (long)&m_sQuad; 127 | #endif // EMSCRIPTEN 128 | 129 | // vertex 130 | int diff = offsetof( ccV3F_C4B_T2F, vertices); 131 | glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); 132 | 133 | // texCoods 134 | diff = offsetof( ccV3F_C4B_T2F, texCoords); 135 | glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); 136 | 137 | // color 138 | diff = offsetof( ccV3F_C4B_T2F, colors); 139 | glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); 140 | 141 | 142 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 143 | 144 | CHECK_GL_ERROR_DEBUG(); 145 | 146 | 147 | #if CC_SPRITE_DEBUG_DRAW == 1 148 | // draw bounding box 149 | CCPoint vertices[4]={ 150 | ccp(m_sQuad.tl.vertices.x,m_sQuad.tl.vertices.y), 151 | ccp(m_sQuad.bl.vertices.x,m_sQuad.bl.vertices.y), 152 | ccp(m_sQuad.br.vertices.x,m_sQuad.br.vertices.y), 153 | ccp(m_sQuad.tr.vertices.x,m_sQuad.tr.vertices.y), 154 | }; 155 | ccDrawPoly(vertices, 4, true); 156 | #elif CC_SPRITE_DEBUG_DRAW == 2 157 | // draw texture box 158 | CCSize s = this->getTextureRect().size; 159 | CCPoint offsetPix = this->getOffsetPosition(); 160 | CCPoint vertices[4] = { 161 | ccp(offsetPix.x,offsetPix.y), ccp(offsetPix.x+s.width,offsetPix.y), 162 | ccp(offsetPix.x+s.width,offsetPix.y+s.height), ccp(offsetPix.x,offsetPix.y+s.height) 163 | }; 164 | ccDrawPoly(vertices, 4, true); 165 | #endif // CC_SPRITE_DEBUG_DRAW 166 | 167 | 168 | 169 | CC_INCREMENT_GL_DRAWS(1); 170 | 171 | CC_PROFILER_STOP_CATEGORY(kCCProfilerCategorySprite, "CCSprite - draw"); 172 | } 173 | 174 | void Star::onUpdate(float delta) 175 | { 176 | CCPoint curPos = getPosition(); 177 | if ( curPos.equals(destPos) ) 178 | { 179 | setPosition(destPos); 180 | } 181 | 182 | float speedX = 0.f; 183 | float speedY = 0.f; 184 | if ( fabs(curPos.x - destPos.x) < FLT_EPSILON ) 185 | { 186 | speedX = 0.f; 187 | } 188 | else if (curPos.x < destPos.x) 189 | { 190 | speedX = MOVE_SPEED; 191 | } 192 | else 193 | { 194 | speedX = -MOVE_SPEED; 195 | } 196 | 197 | if ( fabs(curPos.y - destPos.y) < FLT_EPSILON ) 198 | { 199 | speedY = 0.f; 200 | } 201 | else if (curPos.y < destPos.y) 202 | { 203 | speedY = MOVE_SPEED; 204 | } 205 | else 206 | { 207 | speedY = -MOVE_SPEED; 208 | } 209 | 210 | float tempPosX = curPos.x + delta * speedX; 211 | if (speedX > 0) 212 | { 213 | if (tempPosX > destPos.x) 214 | { 215 | tempPosX = destPos.x; 216 | } 217 | } 218 | else if (speedX < 0) 219 | { 220 | if (tempPosX < destPos.x) 221 | { 222 | tempPosX = destPos.x; 223 | } 224 | } 225 | 226 | float tempPosY = curPos.y + delta * speedY; 227 | if (speedY > 0) 228 | { 229 | if (tempPosY > destPos.y) 230 | { 231 | tempPosY = destPos.y; 232 | } 233 | } 234 | else if (speedY < 0) 235 | { 236 | if (tempPosY < destPos.y) 237 | { 238 | tempPosY = destPos.y; 239 | } 240 | } 241 | setPosition( ccp(tempPosX, tempPosY) ); 242 | 243 | 244 | /*if ( ((int)curPos.x != (int)destPos.x) || ((int)curPos.y != (int)destPos.y) ) 245 | { 246 | float disX = curPos.x - destPos.x; 247 | float disY = curPos.y - destPos.y; 248 | 249 | CCPoint newPos; 250 | newPos.x = curPos.x - disX * delta * MOVE_SPEED; 251 | newPos.y = curPos.y - disY * delta * MOVE_SPEED; 252 | setPosition(newPos); 253 | }*/ 254 | } 255 | 256 | 257 | std::string Star::getPath() 258 | { 259 | return STAR_PATH[index-1]; 260 | } 261 | -------------------------------------------------------------------------------- /popstart/Classes/Star.h: -------------------------------------------------------------------------------- 1 | #ifndef __POPSTAR_STAR_H__ 2 | #define __POPSTAR_STAR_H__ 3 | 4 | #include "cocos2d.h" 5 | 6 | class HelloWorld; 7 | class Star : public cocos2d::CCSprite 8 | { 9 | public: 10 | Star(int index); 11 | 12 | static Star* create(int index); 13 | 14 | bool isHighLight(); 15 | void setHighLight(bool hl); 16 | int getIndex(); 17 | void setPos(const cocos2d::CCPoint& pos); 18 | cocos2d::CCPoint getDestPos(); 19 | void setDestPos(const cocos2d::CCPoint& pos); 20 | void draw(); 21 | 22 | void onUpdate(float delta); 23 | 24 | virtual bool init(); 25 | 26 | private: 27 | std::string getPath(); 28 | 29 | private: 30 | int index; 31 | bool highlight; // 是否高亮显示 32 | cocos2d::CCPoint destPos; 33 | }; 34 | 35 | #endif // __POPSTAR_STAR_H__ -------------------------------------------------------------------------------- /popstart/Classes/StartLayer.cpp: -------------------------------------------------------------------------------- 1 | #include "GameScene.h" 2 | #include "GameLevel.h" 3 | 4 | #include "StartLayer.h" 5 | 6 | USING_NS_CC; 7 | 8 | 9 | CCScene* StartLayer::scene() 10 | { 11 | // 'scene' is an autorelease object 12 | CCScene *scene = CCScene::create(); 13 | 14 | // 'layer' is an autorelease object 15 | StartLayer *layer = StartLayer::create(); 16 | 17 | // add layer as a child to scene 18 | scene->addChild(layer); 19 | 20 | // return the scene 21 | return scene; 22 | } 23 | 24 | // on "init" you need to initialize your instance 25 | bool StartLayer::init() 26 | { 27 | ////////////////////////////// 28 | // 1. super init first 29 | if ( !CCLayer::init() ) 30 | { 31 | return false; 32 | } 33 | 34 | CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); 35 | CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); 36 | 37 | float scale = visibleSize.width/320.f; 38 | 39 | CCSprite* popStarBg = CCSprite::create("popstar_start.png"); 40 | popStarBg->setPosition(ccp(visibleSize.width/2, visibleSize.height/2)); 41 | popStarBg->setScale(scale); 42 | this->addChild(popStarBg, 0); 43 | 44 | 45 | CCMenuItemImage* item = CCMenuItemImage::create("buttons/default/00010.png", 46 | "buttons/default/00010.png", 47 | "buttons/default/00010.png", 48 | this, 49 | menu_selector(StartLayer::onClickMenu)); 50 | 51 | item->setPosition(ccp(visibleSize.width/2, visibleSize.height/3)); 52 | item->setScale(1.0, 1.0); 53 | 54 | CCMenu* menu = CCMenu::create(item, NULL); 55 | menu->setPosition(CCPointZero); 56 | this->addChild(menu); 57 | 58 | return true; 59 | } 60 | 61 | void StartLayer::onClickMenu(CCObject* obj) 62 | { 63 | changeLayer( this, GameLevel::create() ); 64 | } 65 | -------------------------------------------------------------------------------- /popstart/Classes/StartLayer.h: -------------------------------------------------------------------------------- 1 | #ifndef __START_LAYER_H__ 2 | #define __START_LAYER_H__ 3 | 4 | #include "cocos2d.h" 5 | 6 | class StartLayer : public cocos2d::CCLayer 7 | { 8 | public: 9 | // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone 10 | virtual bool init(); 11 | 12 | static cocos2d::CCScene* scene(); 13 | 14 | // implement the "static node()" method manually 15 | CREATE_FUNC(StartLayer); 16 | 17 | void onClickMenu(cocos2d::CCObject* obj); 18 | 19 | private: 20 | }; 21 | 22 | #endif // __START_LAYER_H__ 23 | -------------------------------------------------------------------------------- /popstart/Resources/CloseNormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/CloseNormal.png -------------------------------------------------------------------------------- /popstart/Resources/CloseSelected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/CloseSelected.png -------------------------------------------------------------------------------- /popstart/Resources/HelloWorld.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/HelloWorld.png -------------------------------------------------------------------------------- /popstart/Resources/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/Thumbs.db -------------------------------------------------------------------------------- /popstart/Resources/buttons/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 48 4 | /svn/PopStar/!svn/ver/11/trunk/Resources/buttons 5 | END 6 | -------------------------------------------------------------------------------- /popstart/Resources/buttons/.svn/entries: -------------------------------------------------------------------------------- 1 | 9 2 | 3 | dir 4 | 11 5 | https://wuzy/svn/PopStar/trunk/Resources/buttons 6 | https://wuzy/svn/PopStar 7 | 8 | 9 | 10 | 2014-03-01T05:58:42.203125Z 11 | 11 12 | wuzy 13 | 14 | 15 | svn:special svn:externals svn:needs-lock 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 0 35 | 36 | default 37 | dir 38 | 39 | -------------------------------------------------------------------------------- /popstart/Resources/buttons/.svn/format: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /popstart/Resources/buttons/default/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 56 4 | /svn/PopStar/!svn/ver/11/trunk/Resources/buttons/default 5 | END 6 | 00010.png 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 66 10 | /svn/PopStar/!svn/ver/14/trunk/Resources/buttons/default/00010.png 11 | END 12 | Thumbs.db 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 66 16 | /svn/PopStar/!svn/ver/11/trunk/Resources/buttons/default/Thumbs.db 17 | END 18 | -------------------------------------------------------------------------------- /popstart/Resources/buttons/default/.svn/entries: -------------------------------------------------------------------------------- 1 | 9 2 | 3 | dir 4 | 11 5 | https://wuzy/svn/PopStar/trunk/Resources/buttons/default 6 | https://wuzy/svn/PopStar 7 | 8 | 9 | 10 | 2014-03-01T05:58:42.203125Z 11 | 11 12 | wuzy 13 | 14 | 15 | svn:special svn:externals svn:needs-lock 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 0 35 | 36 | 00010.png 37 | file 38 | 14 39 | 40 | 41 | 42 | 2014-03-02T07:17:03.853275Z 43 | 79b89d66e30bff7935914e81ec0e4406 44 | 2014-03-02T07:25:19.150150Z 45 | 14 46 | wuzy 47 | has-props 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 4994 69 | 70 | 00011.png 71 | file 72 | 14 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | deleted 93 | 94 | 00012.png 95 | file 96 | 14 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | deleted 117 | 118 | Thumbs.db 119 | file 120 | 121 | 122 | 123 | 124 | 2014-02-26T09:39:26.656000Z 125 | 8fe3ff7d2d86f23a0f92f30fe3bb9a2f 126 | 2014-03-01T05:58:42.203125Z 127 | 11 128 | wuzy 129 | has-props 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 6656 151 | 152 | 00013.png 153 | file 154 | 14 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | deleted 175 | 176 | -------------------------------------------------------------------------------- /popstart/Resources/buttons/default/.svn/format: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /popstart/Resources/buttons/default/.svn/prop-base/00010.png.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /popstart/Resources/buttons/default/.svn/prop-base/Thumbs.db.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /popstart/Resources/buttons/default/.svn/text-base/00010.png.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/buttons/default/.svn/text-base/00010.png.svn-base -------------------------------------------------------------------------------- /popstart/Resources/buttons/default/.svn/text-base/Thumbs.db.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/buttons/default/.svn/text-base/Thumbs.db.svn-base -------------------------------------------------------------------------------- /popstart/Resources/buttons/default/00010.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/buttons/default/00010.png -------------------------------------------------------------------------------- /popstart/Resources/buttons/default/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/buttons/default/Thumbs.db -------------------------------------------------------------------------------- /popstart/Resources/fonts/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 45 4 | /svn/PopStar/!svn/ver/2/trunk/Resources/fonts 5 | END 6 | arial.ttf 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 55 10 | /svn/PopStar/!svn/ver/2/trunk/Resources/fonts/arial.ttf 11 | END 12 | Marker Felt.ttf 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 63 16 | /svn/PopStar/!svn/ver/2/trunk/Resources/fonts/Marker%20Felt.ttf 17 | END 18 | -------------------------------------------------------------------------------- /popstart/Resources/fonts/.svn/entries: -------------------------------------------------------------------------------- 1 | 9 2 | 3 | dir 4 | 11 5 | https://wuzy/svn/PopStar/trunk/Resources/fonts 6 | https://wuzy/svn/PopStar 7 | 8 | 9 | 10 | 2014-02-21T12:01:17.930125Z 11 | 2 12 | wuzy 13 | 14 | 15 | svn:special svn:externals svn:needs-lock 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 04843838-7e6c-4046-b208-0b1562b551ae 28 | 29 | arial.ttf 30 | file 31 | 32 | 33 | 34 | 35 | 2014-02-21T12:31:15.398875Z 36 | 05ada5bd099c819f28fbe4a1de2f0a61 37 | 2014-02-21T12:01:17.930125Z 38 | 2 39 | wuzy 40 | has-props 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 778552 62 | 63 | Marker Felt.ttf 64 | file 65 | 66 | 67 | 68 | 69 | 2014-02-21T12:31:15.414500Z 70 | 07945ed723184ee3146ff31d64b4a003 71 | 2014-02-21T12:01:17.930125Z 72 | 2 73 | wuzy 74 | has-props 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 25776 96 | 97 | -------------------------------------------------------------------------------- /popstart/Resources/fonts/.svn/format: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /popstart/Resources/fonts/.svn/prop-base/Marker Felt.ttf.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /popstart/Resources/fonts/.svn/prop-base/arial.ttf.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /popstart/Resources/fonts/.svn/text-base/Marker Felt.ttf.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/fonts/.svn/text-base/Marker Felt.ttf.svn-base -------------------------------------------------------------------------------- /popstart/Resources/fonts/.svn/text-base/arial.ttf.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/fonts/.svn/text-base/arial.ttf.svn-base -------------------------------------------------------------------------------- /popstart/Resources/fonts/Marker Felt.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/fonts/Marker Felt.ttf -------------------------------------------------------------------------------- /popstart/Resources/fonts/arial.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/fonts/arial.ttf -------------------------------------------------------------------------------- /popstart/Resources/popstar_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/popstar_bg.png -------------------------------------------------------------------------------- /popstart/Resources/popstar_start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/popstar_start.png -------------------------------------------------------------------------------- /popstart/Resources/stars/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 45 4 | /svn/PopStar/!svn/ver/2/trunk/Resources/stars 5 | END 6 | green.png 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 55 10 | /svn/PopStar/!svn/ver/2/trunk/Resources/stars/green.png 11 | END 12 | Thumbs.db 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 55 16 | /svn/PopStar/!svn/ver/2/trunk/Resources/stars/Thumbs.db 17 | END 18 | blue.png 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 54 22 | /svn/PopStar/!svn/ver/2/trunk/Resources/stars/blue.png 23 | END 24 | purple.png 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 56 28 | /svn/PopStar/!svn/ver/2/trunk/Resources/stars/purple.png 29 | END 30 | red.png 31 | K 25 32 | svn:wc:ra_dav:version-url 33 | V 53 34 | /svn/PopStar/!svn/ver/2/trunk/Resources/stars/red.png 35 | END 36 | yellow.png 37 | K 25 38 | svn:wc:ra_dav:version-url 39 | V 56 40 | /svn/PopStar/!svn/ver/2/trunk/Resources/stars/yellow.png 41 | END 42 | -------------------------------------------------------------------------------- /popstart/Resources/stars/.svn/entries: -------------------------------------------------------------------------------- 1 | 9 2 | 3 | dir 4 | 11 5 | https://wuzy/svn/PopStar/trunk/Resources/stars 6 | https://wuzy/svn/PopStar 7 | 8 | 9 | 10 | 2014-02-21T12:01:17.930125Z 11 | 2 12 | wuzy 13 | 14 | 15 | svn:special svn:externals svn:needs-lock 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 04843838-7e6c-4046-b208-0b1562b551ae 28 | 29 | green.png 30 | file 31 | 32 | 33 | 34 | 35 | 2014-02-21T12:31:15.477000Z 36 | 7079ce08f0517749567e40aace1f1592 37 | 2014-02-21T12:01:17.930125Z 38 | 2 39 | wuzy 40 | has-props 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 4939 62 | 63 | Thumbs.db 64 | file 65 | 66 | 67 | 68 | 69 | 2014-03-01T05:58:55.968750Z 70 | d78098a2028842fb130b3c1fc7f0a33a 71 | 2014-02-21T12:01:17.930125Z 72 | 2 73 | wuzy 74 | has-props 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 14848 96 | 97 | blue.png 98 | file 99 | 100 | 101 | 102 | 103 | 2014-02-21T12:31:15.492625Z 104 | bb4f996220ee83e90cf89b45aedde098 105 | 2014-02-21T12:01:17.930125Z 106 | 2 107 | wuzy 108 | has-props 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 4892 130 | 131 | purple.png 132 | file 133 | 134 | 135 | 136 | 137 | 2014-02-21T12:31:15.508250Z 138 | 78e823f9de17fa8204013fd84abc9388 139 | 2014-02-21T12:01:17.930125Z 140 | 2 141 | wuzy 142 | has-props 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 4898 164 | 165 | red.png 166 | file 167 | 168 | 169 | 170 | 171 | 2014-02-21T12:31:15.508250Z 172 | 540c0ccd2b81013b0f03eae1daa93e73 173 | 2014-02-21T12:01:17.930125Z 174 | 2 175 | wuzy 176 | has-props 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 4896 198 | 199 | yellow.png 200 | file 201 | 202 | 203 | 204 | 205 | 2014-02-21T12:31:15.523875Z 206 | 370bdfa88b56460ebb24450cfd34dd20 207 | 2014-02-21T12:01:17.930125Z 208 | 2 209 | wuzy 210 | has-props 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 4910 232 | 233 | -------------------------------------------------------------------------------- /popstart/Resources/stars/.svn/format: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /popstart/Resources/stars/.svn/prop-base/Thumbs.db.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /popstart/Resources/stars/.svn/prop-base/blue.png.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /popstart/Resources/stars/.svn/prop-base/green.png.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /popstart/Resources/stars/.svn/prop-base/purple.png.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /popstart/Resources/stars/.svn/prop-base/red.png.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /popstart/Resources/stars/.svn/prop-base/yellow.png.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /popstart/Resources/stars/.svn/text-base/Thumbs.db.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/stars/.svn/text-base/Thumbs.db.svn-base -------------------------------------------------------------------------------- /popstart/Resources/stars/.svn/text-base/blue.png.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/stars/.svn/text-base/blue.png.svn-base -------------------------------------------------------------------------------- /popstart/Resources/stars/.svn/text-base/green.png.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/stars/.svn/text-base/green.png.svn-base -------------------------------------------------------------------------------- /popstart/Resources/stars/.svn/text-base/purple.png.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/stars/.svn/text-base/purple.png.svn-base -------------------------------------------------------------------------------- /popstart/Resources/stars/.svn/text-base/red.png.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/stars/.svn/text-base/red.png.svn-base -------------------------------------------------------------------------------- /popstart/Resources/stars/.svn/text-base/yellow.png.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/stars/.svn/text-base/yellow.png.svn-base -------------------------------------------------------------------------------- /popstart/Resources/stars/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/stars/Thumbs.db -------------------------------------------------------------------------------- /popstart/Resources/stars/blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/stars/blue.png -------------------------------------------------------------------------------- /popstart/Resources/stars/green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/stars/green.png -------------------------------------------------------------------------------- /popstart/Resources/stars/purple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/stars/purple.png -------------------------------------------------------------------------------- /popstart/Resources/stars/red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/stars/red.png -------------------------------------------------------------------------------- /popstart/Resources/stars/yellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/Resources/stars/yellow.png -------------------------------------------------------------------------------- /popstart/proj.android/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /popstart/proj.android/.cproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 33 | 34 | 35 | 45 | 48 | 49 | 50 | 51 | 61 | 64 | 65 | 66 | 67 | 75 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /popstart/proj.android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | popstart 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 25 | clean,full,incremental, 26 | 27 | 28 | ?name? 29 | 30 | 31 | 32 | org.eclipse.cdt.make.core.append_environment 33 | true 34 | 35 | 36 | org.eclipse.cdt.make.core.autoBuildTarget 37 | all 38 | 39 | 40 | org.eclipse.cdt.make.core.buildArguments 41 | -C ${ProjDirPath} NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt -j2 42 | 43 | 44 | org.eclipse.cdt.make.core.buildCommand 45 | ${ProjDirPath}/ANDROID_NDK/ndk-build 46 | 47 | 48 | org.eclipse.cdt.make.core.cleanBuildTarget 49 | clean 50 | 51 | 52 | org.eclipse.cdt.make.core.contents 53 | org.eclipse.cdt.make.core.activeConfigSettings 54 | 55 | 56 | org.eclipse.cdt.make.core.enableAutoBuild 57 | false 58 | 59 | 60 | org.eclipse.cdt.make.core.enableCleanBuild 61 | true 62 | 63 | 64 | org.eclipse.cdt.make.core.enableFullBuild 65 | true 66 | 67 | 68 | org.eclipse.cdt.make.core.fullBuildTarget 69 | all 70 | 71 | 72 | org.eclipse.cdt.make.core.stopOnError 73 | true 74 | 75 | 76 | org.eclipse.cdt.make.core.useDefaultBuildCmd 77 | false 78 | 79 | 80 | 81 | 82 | com.android.ide.eclipse.adt.ApkBuilder 83 | 84 | 85 | 86 | 87 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 88 | full,incremental, 89 | 90 | 91 | 92 | 93 | 94 | com.android.ide.eclipse.adt.AndroidNature 95 | org.eclipse.jdt.core.javanature 96 | org.eclipse.cdt.core.cnature 97 | org.eclipse.cdt.core.ccnature 98 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 99 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 100 | 101 | 102 | 103 | Classes 104 | 2 105 | COCOS2DX/projects/popstart/Classes 106 | 107 | 108 | cocos2dx 109 | 2 110 | COCOS2DX/cocos2dx 111 | 112 | 113 | extensions 114 | 2 115 | COCOS2DX/extensions 116 | 117 | 118 | scripting 119 | 2 120 | COCOS2DX/scripting 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /popstart/proj.android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /popstart/proj.android/README.md: -------------------------------------------------------------------------------- 1 | ## Prerequisites: 2 | 3 | * Android NDK 4 | * Android SDK **OR** Eclipse ADT Bundle 5 | * Android AVD target installed 6 | 7 | ## Building project 8 | 9 | There are two ways of building Android projects. 10 | 11 | 1. Eclipse 12 | 2. Command Line 13 | 14 | ### Import Project in Eclipse 15 | 16 | #### Features: 17 | 18 | 1. Complete workflow from Eclipse, including: 19 | * Build C++. 20 | * Clean C++. 21 | * Build and Run whole project. 22 | * Logcat view. 23 | * Debug Java code. 24 | * Javascript editor. 25 | * Project management. 26 | 2. True C++ editing, including: 27 | * Code completion. 28 | * Jump to definition. 29 | * Refactoring tools etc. 30 | * Quick open C++ files. 31 | 32 | 33 | #### Setup Eclipse Environment (only once) 34 | 35 | 36 | **NOTE:** This step needs to be done only once to setup the Eclipse environment for cocos2d-x projects. Skip this section if you've done this before. 37 | 38 | 1. Download Eclipse ADT bundle from [Google ADT homepage](http://developer.android.com/sdk/index.html) 39 | 40 | **OR** 41 | 42 | Install Eclipse with Java. Add ADT and CDT plugins. 43 | 44 | 2. Only for Windows 45 | 1. Install [Cygwin](http://www.cygwin.com/) with make (select make package from the list during the install). 46 | 2. Add `Cygwin\bin` directory to system PATH variable. 47 | 3. Add this line `none /cygdrive cygdrive binary,noacl,posix=0,user 0 0` to `Cygwin\etc\fstab` file. 48 | 49 | 3. Set up Variables: 50 | 1. Path Variable `COCOS2DX`: 51 | * Eclipse->Preferences->General->Workspace->**Linked Resources** 52 | * Click **New** button to add a Path Variable `COCOS2DX` pointing to the root cocos2d-x directory. 53 | ![Example](https://lh5.googleusercontent.com/-oPpk9kg3e5w/UUOYlq8n7aI/AAAAAAAAsdQ/zLA4eghBH9U/s400/cocos2d-x-eclipse-vars.png) 54 | 55 | 2. C/C++ Environment Variable `NDK_ROOT`: 56 | * Eclipse->Preferences->C/C++->Build->**Environment**. 57 | * Click **Add** button and add a new variable `NDK_ROOT` pointing to the root NDK directory. 58 | ![Example](https://lh3.googleusercontent.com/-AVcY8IAT0_g/UUOYltoRobI/AAAAAAAAsdM/22D2J9u3sig/s400/cocos2d-x-eclipse-ndk.png) 59 | * Only for Windows: Add new variables **CYGWIN** with value `nodosfilewarning` and **SHELLOPTS** with value `igncr` 60 | 61 | 4. Import libcocos2dx library project: 62 | 1. File->New->Project->Android Project From Existing Code. 63 | 2. Click **Browse** button and open `cocos2d-x/cocos2dx/platform/android/java` directory. 64 | 3. Click **Finish** to add project. 65 | 66 | #### Adding and running from Eclipse 67 | 68 | ![Example](https://lh3.googleusercontent.com/-SLBOu6e3QbE/UUOcOXYaGqI/AAAAAAAAsdo/tYBY2SylOSM/s288/cocos2d-x-eclipse-project-from-code.png) ![Import](https://lh5.googleusercontent.com/-XzC9Pn65USc/UUOcOTAwizI/AAAAAAAAsdk/4b6YM-oim9Y/s400/cocos2d-x-eclipse-import-project.png) 69 | 70 | 1. File->New->Project->Android Project From Existing Code 71 | 2. **Browse** to your project directory. eg: `cocos2d-x/cocos2dx/samples/Cpp/TestCpp/proj.android/` 72 | 3. Add the project 73 | 4. Click **Run** or **Debug** to compile C++ followed by Java and to run on connected device or emulator. 74 | 75 | 76 | ### Running project from Command Line 77 | 78 | $ cd cocos2d-x/samples/Cpp/TestCpp/proj.android/ 79 | $ export NDK_ROOT=/path/to/ndk 80 | $ ./build_native.sh 81 | $ ant debug install 82 | 83 | If the last command results in sdk.dir missing error then do: 84 | 85 | $ android list target 86 | $ android update project -p . -t (id from step 6) 87 | $ android update project -p cocos2d-x/cocos2dx/platform/android/java/ -t (id from step 6) 88 | -------------------------------------------------------------------------------- /popstart/proj.android/ant.properties: -------------------------------------------------------------------------------- 1 | # This file is used to override default values used by the Ant build system. 2 | # 3 | # This file must be checked into Version Control Systems, as it is 4 | # integral to the build system of your project. 5 | 6 | # This file is only used by the Ant script. 7 | 8 | # You can use this to override default values such as 9 | # 'source.dir' for the location of your java source folder and 10 | # 'out.dir' for the location of your output folder. 11 | 12 | # You can also use it define how the release builds are signed by declaring 13 | # the following properties: 14 | # 'key.store' for the location of your keystore and 15 | # 'key.alias' for the name of the key to use. 16 | # The password will be asked during the build when you use the 'release' target. 17 | 18 | -------------------------------------------------------------------------------- /popstart/proj.android/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 29 | 30 | 31 | 40 | 41 | 42 | 43 | 47 | 48 | 60 | 61 | 62 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /popstart/proj.android/build_native.sh: -------------------------------------------------------------------------------- 1 | APPNAME="popstart" 2 | 3 | # options 4 | 5 | buildexternalsfromsource= 6 | 7 | usage(){ 8 | cat << EOF 9 | usage: $0 [options] 10 | 11 | Build C/C++ code for $APPNAME using Android NDK 12 | 13 | OPTIONS: 14 | -s Build externals from source 15 | -h this help 16 | EOF 17 | } 18 | 19 | while getopts "sh" OPTION; do 20 | case "$OPTION" in 21 | s) 22 | buildexternalsfromsource=1 23 | ;; 24 | h) 25 | usage 26 | exit 0 27 | ;; 28 | esac 29 | done 30 | 31 | # paths 32 | 33 | if [ -z "${NDK_ROOT+aaa}" ];then 34 | echo "please define NDK_ROOT" 35 | exit 1 36 | fi 37 | 38 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 39 | # ... use paths relative to current directory 40 | COCOS2DX_ROOT="$DIR/../../.." 41 | APP_ROOT="$DIR/.." 42 | APP_ANDROID_ROOT="$DIR" 43 | 44 | echo "NDK_ROOT = $NDK_ROOT" 45 | echo "COCOS2DX_ROOT = $COCOS2DX_ROOT" 46 | echo "APP_ROOT = $APP_ROOT" 47 | echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT" 48 | 49 | # make sure assets is exist 50 | if [ -d "$APP_ANDROID_ROOT"/assets ]; then 51 | rm -rf "$APP_ANDROID_ROOT"/assets 52 | fi 53 | 54 | mkdir "$APP_ANDROID_ROOT"/assets 55 | 56 | # copy resources 57 | for file in "$APP_ROOT"/Resources/* 58 | do 59 | if [ -d "$file" ]; then 60 | cp -rf "$file" "$APP_ANDROID_ROOT"/assets 61 | fi 62 | 63 | if [ -f "$file" ]; then 64 | cp "$file" "$APP_ANDROID_ROOT"/assets 65 | fi 66 | done 67 | 68 | # run ndk-build 69 | if [[ "$buildexternalsfromsource" ]]; then 70 | echo "Building external dependencies from source" 71 | "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ 72 | "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source" 73 | else 74 | echo "Using prebuilt externals" 75 | "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ 76 | "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt" 77 | fi 78 | -------------------------------------------------------------------------------- /popstart/proj.android/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := cocos2dcpp_shared 6 | 7 | LOCAL_MODULE_FILENAME := libcocos2dcpp 8 | 9 | LOCAL_SRC_FILES := hellocpp/main.cpp \ 10 | ../../Classes/AppDelegate.cpp \ 11 | ../../Classes/HelloWorldScene.cpp 12 | 13 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes 14 | 15 | LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static 16 | LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static 17 | LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static 18 | LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static 19 | LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static 20 | 21 | include $(BUILD_SHARED_LIBRARY) 22 | 23 | $(call import-module,cocos2dx) 24 | $(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) 25 | $(call import-module,CocosDenshion/android) 26 | $(call import-module,extensions) 27 | $(call import-module,external/Box2D) 28 | $(call import-module,external/chipmunk) 29 | -------------------------------------------------------------------------------- /popstart/proj.android/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_STL := gnustl_static 2 | APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1 3 | -------------------------------------------------------------------------------- /popstart/proj.android/jni/hellocpp/main.cpp: -------------------------------------------------------------------------------- 1 | #include "AppDelegate.h" 2 | #include "cocos2d.h" 3 | #include "CCEventType.h" 4 | #include "platform/android/jni/JniHelper.h" 5 | #include 6 | #include 7 | 8 | #define LOG_TAG "main" 9 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) 10 | 11 | using namespace cocos2d; 12 | 13 | extern "C" 14 | { 15 | 16 | jint JNI_OnLoad(JavaVM *vm, void *reserved) 17 | { 18 | JniHelper::setJavaVM(vm); 19 | 20 | return JNI_VERSION_1_4; 21 | } 22 | 23 | void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h) 24 | { 25 | if (!CCDirector::sharedDirector()->getOpenGLView()) 26 | { 27 | CCEGLView *view = CCEGLView::sharedOpenGLView(); 28 | view->setFrameSize(w, h); 29 | 30 | AppDelegate *pAppDelegate = new AppDelegate(); 31 | CCApplication::sharedApplication()->run(); 32 | } 33 | else 34 | { 35 | ccGLInvalidateStateCache(); 36 | CCShaderCache::sharedShaderCache()->reloadDefaultShaders(); 37 | ccDrawInit(); 38 | CCTextureCache::reloadAllTextures(); 39 | CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_FOREGROUND, NULL); 40 | CCDirector::sharedDirector()->setGLDefaultValues(); 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /popstart/proj.android/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /popstart/proj.android/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-8 12 | 13 | android.library.reference.1=../../../cocos2dx/platform/android/java 14 | -------------------------------------------------------------------------------- /popstart/proj.android/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.android/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /popstart/proj.android/res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.android/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /popstart/proj.android/res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.android/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /popstart/proj.android/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | popstart 4 | 5 | -------------------------------------------------------------------------------- /popstart/proj.android/src/com/MyCompany/popstart/popstart.java: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | Copyright (c) 2010-2011 cocos2d-x.org 3 | 4 | http://www.cocos2d-x.org 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | ****************************************************************************/ 24 | package com.MyCompany.popstart; 25 | 26 | import org.cocos2dx.lib.Cocos2dxActivity; 27 | import org.cocos2dx.lib.Cocos2dxGLSurfaceView; 28 | 29 | import android.os.Bundle; 30 | 31 | public class popstart extends Cocos2dxActivity{ 32 | 33 | protected void onCreate(Bundle savedInstanceState){ 34 | super.onCreate(savedInstanceState); 35 | } 36 | 37 | public Cocos2dxGLSurfaceView onCreateView() { 38 | Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this); 39 | // popstart should create stencil buffer 40 | glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8); 41 | 42 | return glSurfaceView; 43 | } 44 | 45 | static { 46 | System.loadLibrary("cocos2dcpp"); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /popstart/proj.ios/AppController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class RootViewController; 4 | 5 | @interface AppController : NSObject { 6 | UIWindow *window; 7 | RootViewController *viewController; 8 | } 9 | 10 | @end 11 | 12 | -------------------------------------------------------------------------------- /popstart/proj.ios/AppController.mm: -------------------------------------------------------------------------------- 1 | #import "AppController.h" 2 | #import "EAGLView.h" 3 | #import "cocos2d.h" 4 | #import "AppDelegate.h" 5 | #import "RootViewController.h" 6 | 7 | @implementation AppController 8 | 9 | #pragma mark - 10 | #pragma mark Application lifecycle 11 | 12 | // cocos2d application instance 13 | static AppDelegate s_sharedApplication; 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 16 | 17 | // Override point for customization after application launch. 18 | 19 | // Add the view controller's view to the window and display. 20 | window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; 21 | 22 | // Init the EAGLView 23 | EAGLView *__glView = [EAGLView viewWithFrame: [window bounds] 24 | pixelFormat: kEAGLColorFormatRGB565 25 | depthFormat: GL_DEPTH24_STENCIL8_OES 26 | preserveBackbuffer: NO 27 | sharegroup: nil 28 | multiSampling: NO 29 | numberOfSamples: 0]; 30 | 31 | // Use RootViewController manage EAGLView 32 | viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; 33 | viewController.wantsFullScreenLayout = YES; 34 | viewController.view = __glView; 35 | 36 | // Set RootViewController to window 37 | if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) 38 | { 39 | // warning: addSubView doesn't work on iOS6 40 | [window addSubview: viewController.view]; 41 | } 42 | else 43 | { 44 | // use this method on ios6 45 | [window setRootViewController:viewController]; 46 | } 47 | 48 | [window makeKeyAndVisible]; 49 | 50 | [[UIApplication sharedApplication] setStatusBarHidden:true]; 51 | 52 | cocos2d::CCApplication::sharedApplication()->run(); 53 | 54 | return YES; 55 | } 56 | 57 | 58 | - (void)applicationWillResignActive:(UIApplication *)application { 59 | /* 60 | Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 61 | Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 62 | */ 63 | cocos2d::CCDirector::sharedDirector()->pause(); 64 | } 65 | 66 | - (void)applicationDidBecomeActive:(UIApplication *)application { 67 | /* 68 | Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 69 | */ 70 | cocos2d::CCDirector::sharedDirector()->resume(); 71 | } 72 | 73 | - (void)applicationDidEnterBackground:(UIApplication *)application { 74 | /* 75 | Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 76 | If your application supports background execution, called instead of applicationWillTerminate: when the user quits. 77 | */ 78 | cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground(); 79 | } 80 | 81 | - (void)applicationWillEnterForeground:(UIApplication *)application { 82 | /* 83 | Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. 84 | */ 85 | cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground(); 86 | } 87 | 88 | - (void)applicationWillTerminate:(UIApplication *)application { 89 | /* 90 | Called when the application is about to terminate. 91 | See also applicationDidEnterBackground:. 92 | */ 93 | } 94 | 95 | 96 | #pragma mark - 97 | #pragma mark Memory management 98 | 99 | - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { 100 | /* 101 | Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. 102 | */ 103 | } 104 | 105 | 106 | - (void)dealloc { 107 | [window release]; 108 | [super dealloc]; 109 | } 110 | 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /popstart/proj.ios/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.ios/Default-568h@2x.png -------------------------------------------------------------------------------- /popstart/proj.ios/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.ios/Default.png -------------------------------------------------------------------------------- /popstart/proj.ios/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.ios/Default@2x.png -------------------------------------------------------------------------------- /popstart/proj.ios/Icon-114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.ios/Icon-114.png -------------------------------------------------------------------------------- /popstart/proj.ios/Icon-120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.ios/Icon-120.png -------------------------------------------------------------------------------- /popstart/proj.ios/Icon-144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.ios/Icon-144.png -------------------------------------------------------------------------------- /popstart/proj.ios/Icon-152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.ios/Icon-152.png -------------------------------------------------------------------------------- /popstart/proj.ios/Icon-57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.ios/Icon-57.png -------------------------------------------------------------------------------- /popstart/proj.ios/Icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.ios/Icon-72.png -------------------------------------------------------------------------------- /popstart/proj.ios/Icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.ios/Icon-76.png -------------------------------------------------------------------------------- /popstart/proj.ios/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | Icon-57.png 13 | CFBundleIconFiles 14 | 15 | Icon.png 16 | Icon@2x.png 17 | Icon-57.png 18 | Icon-114.png 19 | Icon-72.png 20 | Icon-144.png 21 | Icon-76.png 22 | Icon-120.png 23 | Icon-152.png 24 | 25 | CFBundleIdentifier 26 | com.MyCompany.popstart 27 | CFBundleInfoDictionaryVersion 28 | 6.0 29 | CFBundleName 30 | ${PRODUCT_NAME} 31 | CFBundlePackageType 32 | APPL 33 | CFBundleShortVersionString 34 | 35 | CFBundleSignature 36 | ???? 37 | CFBundleVersion 38 | 1.0 39 | LSRequiresIPhoneOS 40 | 41 | UIAppFonts 42 | 43 | UISupportedInterfaceOrientations 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationPortraitUpsideDown 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /popstart/proj.ios/Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'iphone' target in the 'iphone' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /popstart/proj.ios/RootViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | @interface RootViewController : UIViewController { 5 | 6 | } 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /popstart/proj.ios/RootViewController.mm: -------------------------------------------------------------------------------- 1 | #import "RootViewController.h" 2 | 3 | 4 | @implementation RootViewController 5 | 6 | /* 7 | // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. 8 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 9 | if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { 10 | // Custom initialization 11 | } 12 | return self; 13 | } 14 | */ 15 | 16 | /* 17 | // Implement loadView to create a view hierarchy programmatically, without using a nib. 18 | - (void)loadView { 19 | } 20 | */ 21 | 22 | /* 23 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | } 27 | 28 | */ 29 | // Override to allow orientations other than the default portrait orientation. 30 | // This method is deprecated on ios6 31 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 32 | return UIInterfaceOrientationIsLandscape( interfaceOrientation ); 33 | } 34 | 35 | // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead 36 | - (NSUInteger) supportedInterfaceOrientations{ 37 | #ifdef __IPHONE_6_0 38 | return UIInterfaceOrientationMaskAllButUpsideDown; 39 | #endif 40 | } 41 | 42 | - (BOOL) shouldAutorotate { 43 | return YES; 44 | } 45 | 46 | //fix not hide status on ios7 47 | - (BOOL)prefersStatusBarHidden 48 | { 49 | return YES; 50 | } 51 | 52 | - (void)didReceiveMemoryWarning { 53 | // Releases the view if it doesn't have a superview. 54 | [super didReceiveMemoryWarning]; 55 | 56 | // Release any cached data, images, etc that aren't in use. 57 | } 58 | 59 | - (void)viewDidUnload { 60 | [super viewDidUnload]; 61 | // Release any retained subviews of the main view. 62 | // e.g. self.myOutlet = nil; 63 | } 64 | 65 | 66 | - (void)dealloc { 67 | [super dealloc]; 68 | } 69 | 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /popstart/proj.ios/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | // Under iOS and the Simulator, we can use an alternate Accelerometer interface 4 | #import "AccelerometerSimulation.h" 5 | 6 | int main(int argc, char *argv[]) { 7 | 8 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 9 | int retVal = UIApplicationMain(argc, argv, nil, @"AppController"); 10 | [pool release]; 11 | return retVal; 12 | } 13 | -------------------------------------------------------------------------------- /popstart/proj.ios/popstart.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /popstart/proj.ios/popstart.xcodeproj/project.xcworkspace/xcuserdata/zeroyang.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.ios/popstart.xcodeproj/project.xcworkspace/xcuserdata/zeroyang.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /popstart/proj.ios/popstart.xcodeproj/xcuserdata/zeroyang.xcuserdatad/xcschemes/popstart.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /popstart/proj.ios/popstart.xcodeproj/xcuserdata/zeroyang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | popstart.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 1D6058900D05DD3D006BFB54 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /popstart/proj.linux/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | popstart 4 | 5 | 6 | libBox2D 7 | libChipmunk 8 | libcocos2d 9 | libCocosDenshion 10 | libextension 11 | 12 | 13 | 14 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 15 | clean,full,incremental, 16 | 17 | 18 | ?children? 19 | ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|?name?=entry\\\\\\\|\\\|\|| 20 | 21 | 22 | ?name? 23 | 24 | 25 | 26 | org.eclipse.cdt.make.core.append_environment 27 | true 28 | 29 | 30 | org.eclipse.cdt.make.core.autoBuildTarget 31 | all 32 | 33 | 34 | org.eclipse.cdt.make.core.buildArguments 35 | 36 | 37 | 38 | org.eclipse.cdt.make.core.buildCommand 39 | make 40 | 41 | 42 | org.eclipse.cdt.make.core.buildLocation 43 | ${workspace_loc:/popstart/Debug} 44 | 45 | 46 | org.eclipse.cdt.make.core.cleanBuildTarget 47 | clean 48 | 49 | 50 | org.eclipse.cdt.make.core.contents 51 | org.eclipse.cdt.make.core.activeConfigSettings 52 | 53 | 54 | org.eclipse.cdt.make.core.enableAutoBuild 55 | false 56 | 57 | 58 | org.eclipse.cdt.make.core.enableCleanBuild 59 | true 60 | 61 | 62 | org.eclipse.cdt.make.core.enableFullBuild 63 | true 64 | 65 | 66 | org.eclipse.cdt.make.core.fullBuildTarget 67 | all 68 | 69 | 70 | org.eclipse.cdt.make.core.stopOnError 71 | true 72 | 73 | 74 | org.eclipse.cdt.make.core.useDefaultBuildCmd 75 | true 76 | 77 | 78 | 79 | 80 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 81 | full,incremental, 82 | 83 | 84 | 85 | 86 | 87 | org.eclipse.cdt.core.cnature 88 | org.eclipse.cdt.core.ccnature 89 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 90 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 91 | 92 | 93 | 94 | Classes 95 | 2 96 | PARENT-1-PROJECT_LOC/Classes 97 | 98 | 99 | 100 | 101 | 1345106176896 102 | Classes/ExtensionsTest 103 | 10 104 | 105 | org.eclipse.ui.ide.multiFilter 106 | 1.0-name-matches-true-false-EditBoxTest 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /popstart/proj.linux/Makefile: -------------------------------------------------------------------------------- 1 | EXECUTABLE = popstart 2 | 3 | INCLUDES = -I.. -I../Classes 4 | 5 | SOURCES = main.cpp \ 6 | ../Classes/AppDelegate.cpp \ 7 | ../Classes/HelloWorldScene.cpp 8 | 9 | COCOS_ROOT = ../../.. 10 | include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk 11 | 12 | SHAREDLIBS += -lcocos2d 13 | COCOS_LIBS = $(LIB_DIR)/libcocos2d.so 14 | 15 | $(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) 16 | @mkdir -p $(@D) 17 | $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) 18 | 19 | $(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) 20 | @mkdir -p $(@D) 21 | $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ 22 | 23 | $(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) 24 | @mkdir -p $(@D) 25 | $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ 26 | -------------------------------------------------------------------------------- /popstart/proj.linux/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TXTCOLOR_DEFAULT="\033[0;m" 4 | TXTCOLOR_RED="\033[0;31m" 5 | TXTCOLOR_GREEN="\033[0;32m" 6 | 7 | COCOS2DX20_TRUNK=`pwd`/../../.. 8 | OUTPUT_DEBUG=$COCOS2DX20_TRUNK/lib/linux/debug/ 9 | OUTPUT_RELEASE=$COCOS2DX20_TRUNK/lib/linux/release/ 10 | 11 | check_make_result() 12 | { 13 | if [ 0 != $? ]; then 14 | exit 1 15 | fi 16 | } 17 | 18 | DEPENDS='libx11-dev' 19 | DEPENDS+=' libxmu-dev' 20 | DEPENDS+=' libglu1-mesa-dev' 21 | DEPENDS+=' libgl2ps-dev' 22 | DEPENDS+=' libxi-dev' 23 | DEPENDS+=' libglfw-dev' 24 | DEPENDS+=' g++' 25 | DEPENDS+=' libzip-dev' 26 | DEPENDS+=' libcurl4-gnutls-dev' 27 | DEPENDS+=' libfontconfig1-dev' 28 | DEPENDS+=' libsqlite3-dev' 29 | DEPENDS+=' libglew-dev' 30 | 31 | for i in $DEPENDS; do 32 | PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $i | grep "install ok installed") 33 | echo Checking for $i: $PKG_OK 34 | if [ "" == "$PKG_OK" ]; then 35 | echo -e $TXTCOLOR_GREEN"No $i. Setting up $i, please enter your password:"$TXTCOLOR_DEFAULT 36 | sudo apt-get --force-yes --yes install $i 37 | fi 38 | done 39 | 40 | mkdir -p $OUTPUT_DEBUG 41 | mkdir -p $OUTPUT_RELEASE 42 | 43 | make -C $COCOS2DX20_TRUNK/external/Box2D/proj.linux DEBUG=1 44 | check_make_result 45 | 46 | make -C $COCOS2DX20_TRUNK/external/chipmunk/proj.linux DEBUG=1 47 | check_make_result 48 | 49 | make -C $COCOS2DX20_TRUNK/cocos2dx/proj.linux DEBUG=1 50 | check_make_result 51 | 52 | make -C $COCOS2DX20_TRUNK/CocosDenshion/proj.linux DEBUG=1 53 | check_make_result 54 | 55 | make -C $COCOS2DX20_TRUNK/extensions/proj.linux DEBUG=1 56 | check_make_result 57 | 58 | make DEBUG=1 59 | check_make_result 60 | -------------------------------------------------------------------------------- /popstart/proj.linux/main.cpp: -------------------------------------------------------------------------------- 1 | #include "../Classes/AppDelegate.h" 2 | #include "cocos2d.h" 3 | #include "CCEGLView.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | USING_NS_CC; 11 | 12 | int main(int argc, char **argv) 13 | { 14 | // create the application instance 15 | AppDelegate app; 16 | CCEGLView* eglView = CCEGLView::sharedOpenGLView(); 17 | eglView->setFrameSize(800, 480); 18 | return CCApplication::sharedApplication()->run(); 19 | } 20 | -------------------------------------------------------------------------------- /popstart/proj.mac/AppController.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | Copyright (c) 2010 cocos2d-x.org 3 | 4 | http://www.cocos2d-x.org 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | ****************************************************************************/ 24 | 25 | #pragma once 26 | 27 | #import "cocos2d.h" 28 | #import "EAGLView.h" 29 | 30 | @interface AppController : NSObject 31 | { 32 | NSWindow *window; 33 | EAGLView *glView; 34 | } 35 | 36 | @property (nonatomic, assign) IBOutlet NSWindow* window; 37 | @property (nonatomic, assign) IBOutlet EAGLView* glView; 38 | 39 | -(IBAction) toggleFullScreen:(id)sender; 40 | -(IBAction) exitFullScreen:(id)sender; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /popstart/proj.mac/AppController.mm: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | Copyright (c) 2010 cocos2d-x.org 3 | 4 | http://www.cocos2d-x.org 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | ****************************************************************************/ 24 | 25 | #import "AppController.h" 26 | #import "AppDelegate.h" 27 | 28 | @implementation AppController 29 | 30 | static AppDelegate s_sharedApplication; 31 | 32 | @synthesize window, glView; 33 | 34 | -(void) applicationDidFinishLaunching:(NSNotification *)aNotification 35 | { 36 | // create the window 37 | // note that using NSResizableWindowMask causes the window to be a little 38 | // smaller and therefore ipad graphics are not loaded 39 | NSRect rect = NSMakeRect(200, 200, 480, 320); 40 | window = [[NSWindow alloc] initWithContentRect:rect 41 | styleMask:( NSClosableWindowMask | NSTitledWindowMask ) 42 | backing:NSBackingStoreBuffered 43 | defer:YES]; 44 | 45 | NSOpenGLPixelFormatAttribute attributes[] = { 46 | NSOpenGLPFADoubleBuffer, 47 | NSOpenGLPFADepthSize, 24, 48 | NSOpenGLPFAStencilSize, 8, 49 | 0 50 | }; 51 | 52 | NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes] autorelease]; 53 | 54 | // allocate our GL view 55 | // (isn't there already a shared EAGLView?) 56 | glView = [[EAGLView alloc] initWithFrame:rect pixelFormat:pixelFormat]; 57 | 58 | // set window parameters 59 | [window becomeFirstResponder]; 60 | [window setContentView:glView]; 61 | [window setTitle:@"HelloCpp"]; 62 | [window makeKeyAndOrderFront:self]; 63 | [window setAcceptsMouseMovedEvents:NO]; 64 | 65 | cocos2d::CCApplication::sharedApplication()->run(); 66 | } 67 | 68 | -(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication 69 | { 70 | return YES; 71 | } 72 | 73 | -(void) dealloc 74 | { 75 | cocos2d::CCDirector::sharedDirector()->end(); 76 | [super dealloc]; 77 | } 78 | 79 | #pragma mark - 80 | #pragma mark IB Actions 81 | 82 | -(IBAction) toggleFullScreen:(id)sender 83 | { 84 | EAGLView* pView = [EAGLView sharedEGLView]; 85 | [pView setFullScreen:!pView.isFullScreen]; 86 | } 87 | 88 | -(IBAction) exitFullScreen:(id)sender 89 | { 90 | [[EAGLView sharedEGLView] setFullScreen:NO]; 91 | } 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /popstart/proj.mac/Icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.mac/Icon.icns -------------------------------------------------------------------------------- /popstart/proj.mac/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | Icon 11 | CFBundleIdentifier 12 | com.MyCompany.popstart 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2012. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /popstart/proj.mac/Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Paralaxer' target in the 'Paralaxer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /popstart/proj.mac/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /popstart/proj.mac/main.m: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | Copyright (c) 2010 cocos2d-x.org 3 | 4 | http://www.cocos2d-x.org 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | ****************************************************************************/ 24 | 25 | #import 26 | 27 | int main(int argc, char *argv[]) 28 | { 29 | return NSApplicationMain(argc, (const char **)argv); 30 | } 31 | -------------------------------------------------------------------------------- /popstart/proj.win32/main.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "AppDelegate.h" 3 | #include "CCEGLView.h" 4 | 5 | USING_NS_CC; 6 | 7 | int APIENTRY _tWinMain(HINSTANCE hInstance, 8 | HINSTANCE hPrevInstance, 9 | LPTSTR lpCmdLine, 10 | int nCmdShow) 11 | { 12 | UNREFERENCED_PARAMETER(hPrevInstance); 13 | UNREFERENCED_PARAMETER(lpCmdLine); 14 | 15 | // create the application instance 16 | AppDelegate app; 17 | CCEGLView* eglView = CCEGLView::sharedOpenGLView(); 18 | eglView->setViewName("popstart"); 19 | eglView->setFrameSize(480, 320); 20 | return CCApplication::sharedApplication()->run(); 21 | } 22 | -------------------------------------------------------------------------------- /popstart/proj.win32/main.h: -------------------------------------------------------------------------------- 1 | #ifndef __MAIN_H__ 2 | #define __MAIN_H__ 3 | 4 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 5 | 6 | // Windows Header Files: 7 | #include 8 | #include 9 | 10 | // C RunTime Header Files 11 | #include "CCStdC.h" 12 | 13 | #endif // __MAIN_H__ 14 | -------------------------------------------------------------------------------- /popstart/proj.win32/popstart.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "popstart", "popstart.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}" 5 | ProjectSection(ProjectDependencies) = postProject 6 | {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} 7 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} 8 | {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} 9 | {929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116} 10 | {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} 11 | EndProjectSection 12 | EndProject 13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\..\cocos2dx\proj.win32\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" 14 | EndProject 15 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosDenshion", "..\..\..\CocosDenshion\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" 16 | ProjectSection(ProjectDependencies) = postProject 17 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} 18 | EndProjectSection 19 | EndProject 20 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\..\..\extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}" 21 | ProjectSection(ProjectDependencies) = postProject 22 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} 23 | {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} 24 | {929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116} 25 | {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} 26 | EndProjectSection 27 | EndProject 28 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "..\..\..\external\Box2D\proj.win32\Box2D.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}" 29 | EndProject 30 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\..\..\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" 31 | EndProject 32 | Global 33 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 34 | Debug|Win32 = Debug|Win32 35 | Release|Win32 = Release|Win32 36 | EndGlobalSection 37 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 38 | {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.ActiveCfg = Debug|Win32 39 | {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.Build.0 = Debug|Win32 40 | {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.ActiveCfg = Release|Win32 41 | {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.Build.0 = Release|Win32 42 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.ActiveCfg = Debug|Win32 43 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.Build.0 = Debug|Win32 44 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.ActiveCfg = Release|Win32 45 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.Build.0 = Release|Win32 46 | {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.ActiveCfg = Debug|Win32 47 | {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.Build.0 = Debug|Win32 48 | {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.ActiveCfg = Release|Win32 49 | {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.Build.0 = Release|Win32 50 | {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.ActiveCfg = Debug|Win32 51 | {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.Build.0 = Debug|Win32 52 | {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.ActiveCfg = Release|Win32 53 | {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.Build.0 = Release|Win32 54 | {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.ActiveCfg = Debug|Win32 55 | {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.Build.0 = Debug|Win32 56 | {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32 57 | {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32 58 | {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.ActiveCfg = Debug|Win32 59 | {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.Build.0 = Debug|Win32 60 | {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.ActiveCfg = Release|Win32 61 | {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.Build.0 = Release|Win32 62 | EndGlobalSection 63 | GlobalSection(SolutionProperties) = preSolution 64 | HideSolutionNode = FALSE 65 | EndGlobalSection 66 | EndGlobal 67 | -------------------------------------------------------------------------------- /popstart/proj.win32/popstart.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {76A39BB2-9B84-4C65-98A5-654D86B86F2A} 15 | test_win32 16 | Win32Proj 17 | 18 | 19 | 20 | Application 21 | Unicode 22 | true 23 | v100 24 | v110 25 | v110_xp 26 | v120 27 | v120_xp 28 | 29 | 30 | Application 31 | Unicode 32 | v100 33 | v110 34 | v110_xp 35 | v120 36 | v120_xp 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | <_ProjectFileVersion>10.0.40219.1 50 | $(SolutionDir)$(Configuration).win32\ 51 | $(Configuration).win32\ 52 | true 53 | $(SolutionDir)$(Configuration).win32\ 54 | $(Configuration).win32\ 55 | false 56 | AllRules.ruleset 57 | 58 | 59 | AllRules.ruleset 60 | 61 | 62 | 63 | 64 | $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) 65 | 66 | 67 | $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) 68 | 69 | 70 | 71 | Disabled 72 | $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\external;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\extensions;..\Classes;..;%(AdditionalIncludeDirectories) 73 | WIN32;_DEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 74 | true 75 | EnableFastChecks 76 | MultiThreadedDebugDLL 77 | 78 | 79 | Level3 80 | EditAndContinue 81 | 4267;4251;4244;%(DisableSpecificWarnings) 82 | 83 | 84 | libExtensions.lib;libcocos2d.lib;libCocosDenshion.lib;opengl32.lib;glew32.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;pthreadVCE2.lib;websockets.lib;%(AdditionalDependencies) 85 | $(OutDir)$(ProjectName).exe 86 | $(OutDir);%(AdditionalLibraryDirectories) 87 | true 88 | Windows 89 | MachineX86 90 | 91 | 92 | 93 | 94 | 95 | 96 | if not exist "$(OutDir)" mkdir "$(OutDir)" 97 | xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" 98 | 99 | 100 | 101 | 102 | MaxSpeed 103 | true 104 | $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\external;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\extensions;..\Classes;..;%(AdditionalIncludeDirectories) 105 | WIN32;NDEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 106 | MultiThreadedDLL 107 | true 108 | 109 | 110 | Level3 111 | ProgramDatabase 112 | 4267;4251;4244;%(DisableSpecificWarnings) 113 | 114 | 115 | libExtensions.lib;libcocos2d.lib;libCocosDenshion.lib;opengl32.lib;glew32.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;pthreadVCE2.lib;websockets.lib;%(AdditionalDependencies) 116 | $(OutDir)$(ProjectName).exe 117 | $(OutDir);%(AdditionalLibraryDirectories) 118 | true 119 | Windows 120 | true 121 | true 122 | MachineX86 123 | 124 | 125 | 126 | 127 | 128 | 129 | if not exist "$(OutDir)" mkdir "$(OutDir)" 130 | xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} 146 | false 147 | 148 | 149 | {f8edd7fa-9a51-4e80-baeb-860825d2eac6} 150 | false 151 | 152 | 153 | {21b2c324-891f-48ea-ad1a-5ae13de12e28} 154 | false 155 | 156 | 157 | {929480e7-23c0-4df6-8456-096d71547116} 158 | false 159 | 160 | 161 | {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} 162 | false 163 | 164 | 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /popstart/proj.win32/popstart.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {84a8ebd7-7cf0-47f6-b75e-d441df67da40} 6 | 7 | 8 | {bb6c862e-70e9-49d9-81b7-3829a6f50471} 9 | 10 | 11 | 12 | 13 | win32 14 | 15 | 16 | Classes 17 | 18 | 19 | Classes 20 | 21 | 22 | 23 | 24 | win32 25 | 26 | 27 | Classes 28 | 29 | 30 | Classes 31 | 32 | 33 | -------------------------------------------------------------------------------- /popstart/proj.win32/popstart.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(ProjectDir)..\Resources 5 | WindowsLocalDebugger 6 | 7 | 8 | $(ProjectDir)..\Resources 9 | WindowsLocalDebugger 10 | 11 | -------------------------------------------------------------------------------- /popstart/proj.wp8-xaml/popstart/popstart/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /popstart/proj.wp8-xaml/popstart/popstart/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Documents; 8 | using System.Windows.Input; 9 | using System.Windows.Media; 10 | using System.Windows.Media.Animation; 11 | using System.Windows.Navigation; 12 | using System.Windows.Shapes; 13 | using Microsoft.Phone.Controls; 14 | using Microsoft.Phone.Shell; 15 | 16 | namespace PhoneDirect3DXamlAppInterop 17 | { 18 | public partial class App : Application 19 | { 20 | /// 21 | /// Provides easy access to the root frame of the Phone Application. 22 | /// 23 | /// The root frame of the Phone Application. 24 | public PhoneApplicationFrame RootFrame { get; private set; } 25 | 26 | /// 27 | /// Constructor for the Application object. 28 | /// 29 | public App() 30 | { 31 | // Global handler for uncaught exceptions. 32 | UnhandledException += Application_UnhandledException; 33 | 34 | // Standard Silverlight initialization 35 | InitializeComponent(); 36 | 37 | // Phone-specific initialization 38 | InitializePhoneApplication(); 39 | 40 | // Show graphics profiling information while debugging. 41 | if (System.Diagnostics.Debugger.IsAttached) 42 | { 43 | // Display the current frame rate counters. 44 | Application.Current.Host.Settings.EnableFrameRateCounter = false; 45 | 46 | // Show the areas of the app that are being redrawn in each frame. 47 | //Application.Current.Host.Settings.EnableRedrawRegions = true; 48 | 49 | // Enable non-production analysis visualization mode, 50 | // which shows areas of a page that are handed off to GPU with a colored overlay. 51 | //Application.Current.Host.Settings.EnableCacheVisualization = true; 52 | 53 | // Disable the application idle detection by setting the UserIdleDetectionMode property of the 54 | // application's PhoneApplicationService object to Disabled. 55 | // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run 56 | // and consume battery power when the user is not using the phone. 57 | PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; 58 | } 59 | 60 | } 61 | 62 | // Code to execute when the application is launching (eg, from Start) 63 | // This code will not execute when the application is reactivated 64 | private void Application_Launching(object sender, LaunchingEventArgs e) 65 | { 66 | } 67 | 68 | // Code to execute when the application is activated (brought to foreground) 69 | // This code will not execute when the application is first launched 70 | private void Application_Activated(object sender, ActivatedEventArgs e) 71 | { 72 | } 73 | 74 | // Code to execute when the application is deactivated (sent to background) 75 | // This code will not execute when the application is closing 76 | private void Application_Deactivated(object sender, DeactivatedEventArgs e) 77 | { 78 | } 79 | 80 | // Code to execute when the application is closing (eg, user hit Back) 81 | // This code will not execute when the application is deactivated 82 | private void Application_Closing(object sender, ClosingEventArgs e) 83 | { 84 | } 85 | 86 | // Code to execute if a navigation fails 87 | private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) 88 | { 89 | if (System.Diagnostics.Debugger.IsAttached) 90 | { 91 | // A navigation has failed; break into the debugger 92 | System.Diagnostics.Debugger.Break(); 93 | } 94 | } 95 | 96 | // Code to execute on Unhandled Exceptions 97 | private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) 98 | { 99 | if (System.Diagnostics.Debugger.IsAttached) 100 | { 101 | // An unhandled exception has occurred; break into the debugger 102 | System.Diagnostics.Debugger.Break(); 103 | } 104 | } 105 | 106 | #region Phone application initialization 107 | 108 | // Avoid double-initialization 109 | private bool phoneApplicationInitialized = false; 110 | 111 | // Do not add any additional code to this method 112 | private void InitializePhoneApplication() 113 | { 114 | if (phoneApplicationInitialized) 115 | return; 116 | 117 | // Create the frame but don't set it as RootVisual yet; this allows the splash 118 | // screen to remain active until the application is ready to render. 119 | RootFrame = new PhoneApplicationFrame(); 120 | RootFrame.Navigated += CompleteInitializePhoneApplication; 121 | 122 | // Handle navigation failures 123 | RootFrame.NavigationFailed += RootFrame_NavigationFailed; 124 | 125 | // Handle reset requests for clearing the backstack 126 | RootFrame.Navigated += CheckForResetNavigation; 127 | 128 | // Ensure we don't initialize again 129 | phoneApplicationInitialized = true; 130 | } 131 | 132 | // Do not add any additional code to this method 133 | private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e) 134 | { 135 | // Set the root visual to allow the application to render 136 | if (RootVisual != RootFrame) 137 | RootVisual = RootFrame; 138 | 139 | // Remove this handler since it is no longer needed 140 | RootFrame.Navigated -= CompleteInitializePhoneApplication; 141 | } 142 | 143 | private bool _isResume = false; 144 | private void CheckForResetNavigation(object sender, NavigationEventArgs e) 145 | { 146 | if (e.NavigationMode == NavigationMode.Reset) 147 | { 148 | RootFrame.Navigating += HandlerFotResetNavigating; 149 | _isResume = true; 150 | } 151 | else 152 | { 153 | if (_isResume && e.NavigationMode == NavigationMode.Refresh) 154 | { 155 | RootFrame.Navigating -= HandlerFotResetNavigating; 156 | _isResume = false; 157 | } 158 | } 159 | } 160 | 161 | private void HandlerFotResetNavigating(object sender, NavigatingCancelEventArgs e) 162 | { 163 | RootFrame.Navigating -= HandlerFotResetNavigating; 164 | if (e.Uri.OriginalString.Contains("MainPage.xaml")) 165 | { 166 | e.Cancel = true; 167 | } 168 | else 169 | { 170 | RootFrame.Navigated += ClearBackStackAfterReset; 171 | } 172 | _isResume = false; 173 | } 174 | 175 | private void ClearBackStackAfterReset(object sender, NavigationEventArgs e) 176 | { 177 | // Unregister the event so it doesn't get called again 178 | RootFrame.Navigated -= ClearBackStackAfterReset; 179 | 180 | // Only clear the stack for 'new' (forward) navigations 181 | if (e.NavigationMode != NavigationMode.New) 182 | return; 183 | 184 | // For UI consistency, clear the entire page stack 185 | while (RootFrame.RemoveBackEntry() != null) 186 | { 187 | ; // do nothing 188 | } 189 | } 190 | 191 | #endregion 192 | } 193 | } -------------------------------------------------------------------------------- /popstart/proj.wp8-xaml/popstart/popstart/Assets/AlignmentGrid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.wp8-xaml/popstart/popstart/Assets/AlignmentGrid.png -------------------------------------------------------------------------------- /popstart/proj.wp8-xaml/popstart/popstart/Assets/ApplicationIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.wp8-xaml/popstart/popstart/Assets/ApplicationIcon.png -------------------------------------------------------------------------------- /popstart/proj.wp8-xaml/popstart/popstart/Assets/Tiles/FlipCycleTileLarge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.wp8-xaml/popstart/popstart/Assets/Tiles/FlipCycleTileLarge.png -------------------------------------------------------------------------------- /popstart/proj.wp8-xaml/popstart/popstart/Assets/Tiles/FlipCycleTileMedium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.wp8-xaml/popstart/popstart/Assets/Tiles/FlipCycleTileMedium.png -------------------------------------------------------------------------------- /popstart/proj.wp8-xaml/popstart/popstart/Assets/Tiles/FlipCycleTileSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.wp8-xaml/popstart/popstart/Assets/Tiles/FlipCycleTileSmall.png -------------------------------------------------------------------------------- /popstart/proj.wp8-xaml/popstart/popstart/Assets/Tiles/IconicTileMediumLarge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.wp8-xaml/popstart/popstart/Assets/Tiles/IconicTileMediumLarge.png -------------------------------------------------------------------------------- /popstart/proj.wp8-xaml/popstart/popstart/Assets/Tiles/IconicTileSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZeroYang/PopStar/bbd58c48bc9e8211ad70fa1a22b46c1c62ed707d/popstart/proj.wp8-xaml/popstart/popstart/Assets/Tiles/IconicTileSmall.png -------------------------------------------------------------------------------- /popstart/proj.wp8-xaml/popstart/popstart/EditBox.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 |