mirror of https://github.com/axmolengine/axmol.git
Modify the template for win32.
Make it like the HelloWorld project.
This commit is contained in:
parent
d2a116b001
commit
a007aa5f84
|
@ -67,7 +67,7 @@ bool HelloWorld::init()
|
||||||
// position the sprite on the center of the screen
|
// position the sprite on the center of the screen
|
||||||
pSprite->setPosition( ccp(size.width/2, size.height/2) );
|
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);
|
this->addChild(pSprite, 0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -3,10 +3,10 @@ function OnFinish(selProj, selObj) {
|
||||||
var strProjectPath = wizard.FindSymbol('PROJECT_PATH');
|
var strProjectPath = wizard.FindSymbol('PROJECT_PATH');
|
||||||
var strProjectName = wizard.FindSymbol('PROJECT_NAME');
|
var strProjectName = wizard.FindSymbol('PROJECT_NAME');
|
||||||
|
|
||||||
// var WizardVersion = wizard.FindSymbol('WIZARD_VERSION');
|
// var WizardVersion = wizard.FindSymbol('WIZARD_VERSION');
|
||||||
// if(WizardVersion >= 8.0)
|
// if(WizardVersion >= 8.0)
|
||||||
// {
|
// {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Create symbols based on the project name
|
// Create symbols based on the project name
|
||||||
var strSafeProjectName = CreateSafeName(strProjectName);
|
var strSafeProjectName = CreateSafeName(strProjectName);
|
||||||
|
@ -143,10 +143,10 @@ function AddConfigurations(proj, strProjectName) {
|
||||||
// General settings
|
// General settings
|
||||||
var config = proj.Object.Configurations(astrConfigName[nCntr]);
|
var config = proj.Object.Configurations(astrConfigName[nCntr]);
|
||||||
|
|
||||||
// if(wizard.FindSymbol("CCX_USE_UNICODE"))
|
// if(wizard.FindSymbol("CCX_USE_UNICODE"))
|
||||||
config.CharacterSet = charSetUnicode;
|
config.CharacterSet = charSetUnicode;
|
||||||
// else
|
// else
|
||||||
// config.CharacterSet = charSetMBCS;
|
// config.CharacterSet = charSetMBCS;
|
||||||
|
|
||||||
config.OutputDirectory = '$(SolutionDir)$(ConfigurationName).win32'
|
config.OutputDirectory = '$(SolutionDir)$(ConfigurationName).win32'
|
||||||
config.IntermediateDirectory = '$(ConfigurationName).win32';
|
config.IntermediateDirectory = '$(ConfigurationName).win32';
|
||||||
|
@ -245,9 +245,9 @@ function AddConfigurations(proj, strProjectName) {
|
||||||
MidlTool.DLLDataFileName = "";
|
MidlTool.DLLDataFileName = "";
|
||||||
|
|
||||||
// Post-build settings
|
// Post-build settings
|
||||||
// var PostBuildTool = config.Tools("VCPostBuildEventTool");
|
var PostBuildTool = config.Tools("VCPostBuildEventTool");
|
||||||
// PostBuildTool.Description = "Performing registration...";
|
PostBuildTool.Description = "Performing copy resource from Resource to OutDir...";
|
||||||
// PostBuildTool.CommandLine = "\"$(TargetPath)\" /RegServer";
|
PostBuildTool.CommandLine = "copy /Y \"$(ProjectDir)Resource\\*.*\" \"$(OutDir)\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
@ -257,15 +257,15 @@ function AddConfigurations(proj, strProjectName) {
|
||||||
|
|
||||||
function AddPchSettings(proj) {
|
function AddPchSettings(proj) {
|
||||||
try {
|
try {
|
||||||
// var files = proj.Object.Files;
|
// var files = proj.Object.Files;
|
||||||
// var fStdafx = files("StdAfx.cpp");
|
// var fStdafx = files("StdAfx.cpp");
|
||||||
//
|
//
|
||||||
// var nCntr;
|
// var nCntr;
|
||||||
// for(nCntr = 0; nCntr < nNumConfigs; nCntr++)
|
// for(nCntr = 0; nCntr < nNumConfigs; nCntr++)
|
||||||
// {
|
// {
|
||||||
// var config = fStdafx.FileConfigurations(astrConfigName[nCntr]);
|
// var config = fStdafx.FileConfigurations(astrConfigName[nCntr]);
|
||||||
// config.Tool.UsePrecompiledHeader = pchCreateUsingSpecific;
|
// config.Tool.UsePrecompiledHeader = pchCreateUsingSpecific;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -340,16 +340,16 @@ function AddFilesToCustomProj(proj, strProjectName, strProjectPath, InfFile) {
|
||||||
var strTemplate = strTemplatePath + '\\' + strTpl;
|
var strTemplate = strTemplatePath + '\\' + strTpl;
|
||||||
var strFile = strProjectPath + '\\' + strTarget;
|
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("."));
|
var strExt = strName.substr(strName.lastIndexOf("."));
|
||||||
if (strExt == ".bmp" || strExt == ".ico" || strExt == ".gif" || strExt == ".rtf" || strExt == ".css")
|
if (strExt == ".h" || strExt == ".cpp" || strExt == ".c" || strExt == ".rc")
|
||||||
bCopyOnly = true;
|
bCopyOnly = false;
|
||||||
wizard.RenderTemplate(strTemplate, strFile, bCopyOnly);
|
wizard.RenderTemplate(strTemplate, strFile, bCopyOnly);
|
||||||
|
|
||||||
// don't add these files to the project
|
// don't add these files to the project
|
||||||
if (strTarget == strProjectName + ".h" ||
|
if (strTarget == strProjectName + ".h" ||
|
||||||
strTarget == strProjectName + "ps.mk" ||
|
strTarget == strProjectName + "ps.mk" ||
|
||||||
strTarget == strProjectName + "ps.def")
|
strTarget == strProjectName + "ps.def")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
proj.Object.AddFile(strFile);
|
proj.Object.AddFile(strFile);
|
||||||
|
|
|
@ -5,49 +5,92 @@ using namespace cocos2d;
|
||||||
|
|
||||||
CCScene* HelloWorld::scene()
|
CCScene* HelloWorld::scene()
|
||||||
{
|
{
|
||||||
// 'scene' is an autorelease object
|
CCScene * scene = NULL;
|
||||||
CCScene *scene = CCScene::node();
|
do
|
||||||
|
{
|
||||||
// 'layer' is an autorelease object
|
// 'scene' is an autorelease object
|
||||||
HelloWorld *layer = HelloWorld::node();
|
scene = CCScene::node();
|
||||||
|
CCX_BREAK_IF(! scene);
|
||||||
|
|
||||||
// add layer as a child to scene
|
// 'layer' is an autorelease object
|
||||||
scene->addChild(layer);
|
HelloWorld *layer = HelloWorld::node();
|
||||||
|
CCX_BREAK_IF(! layer);
|
||||||
|
|
||||||
// return the scene
|
// add layer as a child to scene
|
||||||
return scene;
|
scene->addChild(layer);
|
||||||
|
} while (0);
|
||||||
|
|
||||||
|
// return the scene
|
||||||
|
return scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
// on "init" you need to initialize your instance
|
// on "init" you need to initialize your instance
|
||||||
bool HelloWorld::init()
|
bool HelloWorld::init()
|
||||||
{
|
{
|
||||||
//////////////////////////////
|
bool bRet = false;
|
||||||
// 1. super init first
|
do
|
||||||
if ( !CCLayer::init() )
|
{
|
||||||
{
|
//////////////////////////////////////////////////////////////////////////
|
||||||
return false;
|
// super init first
|
||||||
}
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/////////////////////////////
|
CCX_BREAK_IF(! CCLayer::init());
|
||||||
// 2. add your codes below...
|
|
||||||
|
|
||||||
// add a label shows "Hello World"
|
|
||||||
// create and initialize a label
|
|
||||||
CCLabel* pLabel = CCLabel::labelWithString("HelloWorld", "Thonburi", 64);
|
|
||||||
|
|
||||||
// ask director the window size
|
//////////////////////////////////////////////////////////////////////////
|
||||||
CGSize size = CCDirector::sharedDirector()->getWinSize();
|
// add your codes below...
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// position the label on the center of the screen
|
// 1. Add a menu item with "X" image, which is clicked to quit the program.
|
||||||
pLabel->setPosition( ccp(size.width / 2, size.height / 2) );
|
|
||||||
|
|
||||||
// add the label as a child to this layer
|
// Create a "close" menu item with close icon, it's an auto release object.
|
||||||
this->addChild(pLabel);
|
CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(
|
||||||
|
"CloseNormal.png",
|
||||||
return true;
|
"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)
|
void HelloWorld::menuCloseCallback(NSObject* pSender)
|
||||||
{
|
{
|
||||||
CCDirector::sharedDirector()->end();
|
// "close" menu item clicked
|
||||||
|
CCDirector::sharedDirector()->end();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,17 +17,17 @@
|
||||||
class HelloWorld : public cocos2d::CCLayer
|
class HelloWorld : public cocos2d::CCLayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
|
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
|
||||||
virtual bool init();
|
virtual bool init();
|
||||||
|
|
||||||
// there's no 'id' in cpp, so we recommand to return the exactly class pointer
|
// there's no 'id' in cpp, so we recommand to return the exactly class pointer
|
||||||
static cocos2d::CCScene* scene();
|
static cocos2d::CCScene* scene();
|
||||||
|
|
||||||
// a selector callback
|
// a selector callback
|
||||||
virtual void menuCloseCallback(NSObject* pSender);
|
virtual void menuCloseCallback(NSObject* pSender);
|
||||||
|
|
||||||
// implement the "static node()" method manually
|
// implement the "static node()" method manually
|
||||||
LAYER_NODE_FUNC(HelloWorld);
|
LAYER_NODE_FUNC(HelloWorld);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _HELLOWORLD_SCENE_H_
|
#endif // _HELLOWORLD_SCENE_H_
|
|
@ -10,3 +10,7 @@ Classes/AppDelegate.cpp
|
||||||
|
|
||||||
Classes/HelloWorldScene.h
|
Classes/HelloWorldScene.h
|
||||||
Classes/HelloWorldScene.cpp
|
Classes/HelloWorldScene.cpp
|
||||||
|
|
||||||
|
Resource/CloseSelected.png
|
||||||
|
Resource/CloseNormal.png
|
||||||
|
Resource/HelloWorld.png
|
||||||
|
|
Loading…
Reference in New Issue