#include "HelloWorldScene.h"
using namespace cocos2d;
CCScene* HelloWorld::scene()
{
CCScene * scene = NULL;
do
{
// 'scene' is an autorelease object
scene = CCScene::create();
CC_BREAK_IF(! scene);
// 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create();
CC_BREAK_IF(! layer);
// 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()
{
bool bRet = false;
do
{
//////////////////////////////////////////////////////////////////////////
// super init first
//////////////////////////////////////////////////////////////////////////
CC_BREAK_IF(! CCLayer::init());
//////////////////////////////////////////////////////////////////////////
// add your codes below...
//////////////////////////////////////////////////////////////////////////
// 1. Add a menu item with "X" image, which is clicked to quit the program.
// Create a "close" menu item with close icon, it's an auto release object.
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback));
CC_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::create(pCloseItem, NULL);
pMenu->setPosition(CCPointZero);
CC_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".
CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
CC_BREAK_IF(! pLabel);
// Get window size and place the label upper.
CCSize size = CCDirector::sharedDirector()->getWinSize();
pLabel->setPosition(ccp(size.width / 2, size.height - 50));
// 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::create("HelloWorld.png");
CC_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(CCObject* pSender)
{
// "close" menu item clicked
CCDirector::sharedDirector()->end();
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
msvc.rar (45个子文件)
msvc
CCApplicationWizard.sln 1KB
InstallWizardForVC2010Express.js 8KB
InstallWizardForVC2008Express.js 8KB
InstallWizardForVS2008.js 8KB
CCAppWiz.win32
Templates
1033
proj.win32
resource.h 569B
root.rc 2KB
res
root.ico 47KB
main.cpp 863B
main.h 270B
Classes
AppDelegate.cpp 2KB
HelloWorldScene.h 802B
HelloWorldScene.cpp 3KB
AppDelegate.h 960B
Resources
hello.lua 7KB
Icon.png 9KB
menu1.png 6KB
HelloWorld.png 142KB
hello2.lua 41B
effect1.wav 10KB
background.mp3 125KB
dog.png 26KB
menu2.png 69KB
CloseNormal.png 6KB
crop.png 53KB
Default.png 87KB
land.png 24KB
farm.jpg 113KB
CloseSelected.png 5KB
Templates.inf 1KB
default.vcproj 346B
CCAppWiz.win32.vsdir 130B
Scripts
1033
default.js 18KB
Images
Cocos2d-x.gif 3KB
Background_Cocos2d-x.gif 811B
CCAppWiz.win32.vsz 169B
CCAppWiz.win32.ico 66KB
HTML
1033
features.htm 16KB
default.htm 15KB
CCAppWiz.win32.vcproj 4KB
1033
NewStyles.css 24KB
Images
DottedVert.gif 43B
DottedHori.gif 43B
spacer.gif 43B
InstallWizardForVS2010.js 8KB
InstallWizardForVS2012.js 8KB
共 45 条
- 1
资源评论
jianhai1229
- 粉丝: 13
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功