#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();
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Dialy01.rar (50个子文件)
Dialy01
Resources
pd_dpad.png 18KB
pd_sprites.plist 684B
CloseSelected.png 5KB
CloseNormal.png 6KB
HelloWorld.png 142KB
Classes
AppDelegate.h 960B
HelloWorldScene.h 631B
HelloWorldScene.cpp 3KB
AppDelegate.cpp 1KB
proj.win32
main.cpp 863B
main.h 270B
resource.h 494B
Dialy01.aps 49KB
Dialy01.win32.vcxproj.user 763B
Dialy01.rc 2KB
Dialy01.win32.vcxproj 8KB
DialyLayer.h 331B
Debug.win32
link.read.1.tlog 5KB
Dialy01.win32.exe.embed.manifest.res 472B
vc100.pdb 644KB
link-cvtres.read.1.tlog 2B
link.command.1.tlog 3KB
DialyLayer.obj 153KB
rc.write.1.tlog 570B
DialyScene.obj 93KB
Dialy01.res 47KB
CL.write.1.tlog 4KB
Dialy01.win32.exe.intermediate.manifest 381B
rc.command.1.tlog 1KB
AppDelegate.obj 92KB
cl.command.1.tlog 8KB
Dialy01.win32.exe.embed.manifest 406B
Dialy01.win32.log 3KB
Dialy01.win32.lastbuildstate 47B
link-cvtres.write.1.tlog 2B
mt.read.1.tlog 358B
Dialy01.win32_manifest.rc 228B
main.obj 69KB
mt.write.1.tlog 358B
rc.read.1.tlog 3KB
HelloWorldScene.obj 107KB
CL.read.1.tlog 188KB
vc100.idb 1.35MB
mt.command.1.tlog 452B
link.write.1.tlog 1KB
DialyScene.cpp 239B
res
Dialy01.ico 47KB
Dialy01.win32.vcxproj.filters 3KB
DialyLayer.cpp 854B
DialyScene.h 247B
共 50 条
- 1
啊啊啊宁居士
- 粉丝: 44
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页