diff --git a/HelloWorld/HelloWorldScene.cpp b/HelloWorld/HelloWorldScene.cpp index 974106949f..f18e6c49e6 100644 --- a/HelloWorld/HelloWorldScene.cpp +++ b/HelloWorld/HelloWorldScene.cpp @@ -67,7 +67,7 @@ bool HelloWorld::init() // position the sprite on the center of the screen pSprite->setPosition( ccp(size.width/2, size.height/2) ); - // ad the sprite as a child to this layer + // add the sprite as a child to this layer this->addChild(pSprite, 0); return true; diff --git a/template/CCXAppWiz.vs/CCXAppWiz/Scripts/1033/default.js b/template/CCXAppWiz.vs/CCXAppWiz/Scripts/1033/default.js index 053eea86b5..bf60f61233 100644 --- a/template/CCXAppWiz.vs/CCXAppWiz/Scripts/1033/default.js +++ b/template/CCXAppWiz.vs/CCXAppWiz/Scripts/1033/default.js @@ -3,10 +3,10 @@ function OnFinish(selProj, selObj) { var strProjectPath = wizard.FindSymbol('PROJECT_PATH'); var strProjectName = wizard.FindSymbol('PROJECT_NAME'); - // var WizardVersion = wizard.FindSymbol('WIZARD_VERSION'); - // if(WizardVersion >= 8.0) - // { - // } + // var WizardVersion = wizard.FindSymbol('WIZARD_VERSION'); + // if(WizardVersion >= 8.0) + // { + // } // Create symbols based on the project name var strSafeProjectName = CreateSafeName(strProjectName); @@ -143,10 +143,10 @@ function AddConfigurations(proj, strProjectName) { // General settings var config = proj.Object.Configurations(astrConfigName[nCntr]); - // if(wizard.FindSymbol("CCX_USE_UNICODE")) + // if(wizard.FindSymbol("CCX_USE_UNICODE")) config.CharacterSet = charSetUnicode; - // else - // config.CharacterSet = charSetMBCS; + // else + // config.CharacterSet = charSetMBCS; config.OutputDirectory = '$(SolutionDir)$(ConfigurationName).win32' config.IntermediateDirectory = '$(ConfigurationName).win32'; @@ -245,9 +245,9 @@ function AddConfigurations(proj, strProjectName) { MidlTool.DLLDataFileName = ""; // Post-build settings - // var PostBuildTool = config.Tools("VCPostBuildEventTool"); - // PostBuildTool.Description = "Performing registration..."; - // PostBuildTool.CommandLine = "\"$(TargetPath)\" /RegServer"; + var PostBuildTool = config.Tools("VCPostBuildEventTool"); + PostBuildTool.Description = "Performing copy resource from Resource to OutDir..."; + PostBuildTool.CommandLine = "copy /Y \"$(ProjectDir)Resource\\*.*\" \"$(OutDir)\""; } } catch (e) { @@ -257,15 +257,15 @@ function AddConfigurations(proj, strProjectName) { function AddPchSettings(proj) { try { - // var files = proj.Object.Files; - // var fStdafx = files("StdAfx.cpp"); + // var files = proj.Object.Files; + // var fStdafx = files("StdAfx.cpp"); // - // var nCntr; - // for(nCntr = 0; nCntr < nNumConfigs; nCntr++) - // { - // var config = fStdafx.FileConfigurations(astrConfigName[nCntr]); - // config.Tool.UsePrecompiledHeader = pchCreateUsingSpecific; - // } + // var nCntr; + // for(nCntr = 0; nCntr < nNumConfigs; nCntr++) + // { + // var config = fStdafx.FileConfigurations(astrConfigName[nCntr]); + // config.Tool.UsePrecompiledHeader = pchCreateUsingSpecific; + // } } catch (e) { throw e; @@ -340,16 +340,16 @@ function AddFilesToCustomProj(proj, strProjectName, strProjectPath, InfFile) { var strTemplate = strTemplatePath + '\\' + strTpl; var strFile = strProjectPath + '\\' + strTarget; - var bCopyOnly = false; //"true" will only copy the file from strTemplate to strTarget without rendering/adding to the project + var bCopyOnly = true; //"true" will only copy the file from strTemplate to strTarget without rendering/adding to the project var strExt = strName.substr(strName.lastIndexOf(".")); - if (strExt == ".bmp" || strExt == ".ico" || strExt == ".gif" || strExt == ".rtf" || strExt == ".css") - bCopyOnly = true; + if (strExt == ".h" || strExt == ".cpp" || strExt == ".c" || strExt == ".rc") + bCopyOnly = false; wizard.RenderTemplate(strTemplate, strFile, bCopyOnly); // don't add these files to the project if (strTarget == strProjectName + ".h" || - strTarget == strProjectName + "ps.mk" || - strTarget == strProjectName + "ps.def") + strTarget == strProjectName + "ps.mk" || + strTarget == strProjectName + "ps.def") continue; proj.Object.AddFile(strFile); diff --git a/template/CCXAppWiz.vs/CCXAppWiz/Templates/1033/Classes/HelloWorldScene.cpp b/template/CCXAppWiz.vs/CCXAppWiz/Templates/1033/Classes/HelloWorldScene.cpp index d9c32d7cb0..5844645b0d 100644 --- a/template/CCXAppWiz.vs/CCXAppWiz/Templates/1033/Classes/HelloWorldScene.cpp +++ b/template/CCXAppWiz.vs/CCXAppWiz/Templates/1033/Classes/HelloWorldScene.cpp @@ -5,49 +5,92 @@ using namespace cocos2d; CCScene* HelloWorld::scene() { - // 'scene' is an autorelease object - CCScene *scene = CCScene::node(); - - // 'layer' is an autorelease object - HelloWorld *layer = HelloWorld::node(); + CCScene * scene = NULL; + do + { + // 'scene' is an autorelease object + scene = CCScene::node(); + CCX_BREAK_IF(! scene); - // add layer as a child to scene - scene->addChild(layer); + // 'layer' is an autorelease object + HelloWorld *layer = HelloWorld::node(); + CCX_BREAK_IF(! layer); - // return the scene - return scene; + // add layer as a child to scene + scene->addChild(layer); + } while (0); + + // return the scene + return scene; } // on "init" you need to initialize your instance bool HelloWorld::init() { - ////////////////////////////// - // 1. super init first - if ( !CCLayer::init() ) - { - return false; - } + bool bRet = false; + do + { + ////////////////////////////////////////////////////////////////////////// + // super init first + ////////////////////////////////////////////////////////////////////////// - ///////////////////////////// - // 2. add your codes below... - - // add a label shows "Hello World" - // create and initialize a label - CCLabel* pLabel = CCLabel::labelWithString("HelloWorld", "Thonburi", 64); + CCX_BREAK_IF(! CCLayer::init()); - // ask director the window size - CGSize size = CCDirector::sharedDirector()->getWinSize(); + ////////////////////////////////////////////////////////////////////////// + // add your codes below... + ////////////////////////////////////////////////////////////////////////// - // position the label on the center of the screen - pLabel->setPosition( ccp(size.width / 2, size.height / 2) ); + // 1. Add a menu item with "X" image, which is clicked to quit the program. - // add the label as a child to this layer - this->addChild(pLabel); - - return true; + // Create a "close" menu item with close icon, it's an auto release object. + CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage( + "CloseNormal.png", + "CloseSelected.png", + this, + menu_selector(HelloWorld::menuCloseCallback)); + CCX_BREAK_IF(! pCloseItem); + + // Place the menu item bottom-right conner. + pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20)); + + // Create a menu with the "close" menu item, it's an auto release object. + CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL); + CCX_BREAK_IF(! pMenu); + + // Add the menu to HelloWorld layer as a child layer. + this->addChild(pMenu, 1); + + // 2. Add a label shows "Hello World". + + // Create a label and initialize with string "Hello World". + CCLabel* pLabel = CCLabel::labelWithString("Hello World", "Thonburi", 34); + CCX_BREAK_IF(! pLabel); + + // Get window size and place the label upper. + CGSize size = CCDirector::sharedDirector()->getWinSize(); + pLabel->setPosition(ccp(size.width / 2, size.height - 20)); + + // Add the label to HelloWorld layer as a child layer. + this->addChild(pLabel, 1); + + // 3. Add add a splash screen, show the cocos2d splash image. + CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png"); + CCX_BREAK_IF(! pSprite); + + // Place the sprite on the center of the screen + pSprite->setPosition(ccp(size.width/2, size.height/2)); + + // Add the sprite to HelloWorld layer as a child layer. + this->addChild(pSprite, 0); + + bRet = true; + } while (0); + + return bRet; } void HelloWorld::menuCloseCallback(NSObject* pSender) { - CCDirector::sharedDirector()->end(); + // "close" menu item clicked + CCDirector::sharedDirector()->end(); } diff --git a/template/CCXAppWiz.vs/CCXAppWiz/Templates/1033/Classes/HelloWorldScene.h b/template/CCXAppWiz.vs/CCXAppWiz/Templates/1033/Classes/HelloWorldScene.h index e934402f3e..c5ccc2f37f 100644 --- a/template/CCXAppWiz.vs/CCXAppWiz/Templates/1033/Classes/HelloWorldScene.h +++ b/template/CCXAppWiz.vs/CCXAppWiz/Templates/1033/Classes/HelloWorldScene.h @@ -17,17 +17,17 @@ class HelloWorld : public cocos2d::CCLayer { public: - // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone - virtual bool init(); + // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone + virtual bool init(); - // there's no 'id' in cpp, so we recommand to return the exactly class pointer - static cocos2d::CCScene* scene(); - - // a selector callback - virtual void menuCloseCallback(NSObject* pSender); + // there's no 'id' in cpp, so we recommand to return the exactly class pointer + static cocos2d::CCScene* scene(); + + // a selector callback + virtual void menuCloseCallback(NSObject* pSender); - // implement the "static node()" method manually - LAYER_NODE_FUNC(HelloWorld); + // implement the "static node()" method manually + LAYER_NODE_FUNC(HelloWorld); }; #endif // _HELLOWORLD_SCENE_H_ \ No newline at end of file diff --git a/template/CCXAppWiz.vs/CCXAppWiz/Templates/1033/Templates.inf b/template/CCXAppWiz.vs/CCXAppWiz/Templates/1033/Templates.inf index e8aaaeb05c..ff029e274e 100644 --- a/template/CCXAppWiz.vs/CCXAppWiz/Templates/1033/Templates.inf +++ b/template/CCXAppWiz.vs/CCXAppWiz/Templates/1033/Templates.inf @@ -10,3 +10,7 @@ Classes/AppDelegate.cpp Classes/HelloWorldScene.h Classes/HelloWorldScene.cpp + +Resource/CloseSelected.png +Resource/CloseNormal.png +Resource/HelloWorld.png