cocos2d-x项目101次相遇:在HelloWorld上--建立新场景
-
cocos2d-x 101次相遇 / 文件夹
1 安装和环境搭建 -xcode
2 Scenes , Director, Layers, Sprites
3 建立图片菜单
4 在HelloWorld上--建立新场景
5 添加一个精灵sprite
5.1 缩小sprite并使之完整显示
6 action ,移动sprite
7 3.0 的点击事件,CCTouchDelegate已经停用了
8 使用触摸事件移动 精灵
-
//
-
// CMyFirstScene.cpp
-
// linker
-
//
-
// Created by HeJiasheng on 14-3-12.
-
//
-
//
-
-
#include"CMyFirstScene.h"
-
-
USING_NS_CC;
-
-
-
Scene*CMyFirstScene::createScene()
-
{
-
// 'scene' is an autorelease object
-
auto scene =Scene::create();
-
-
// 'layer' is an autorelease object
-
auto layer =CMyFirstScene::create();
-
-
// add layer as a child to scene
-
scene->addChild(layer);
-
-
// return the scene
-
return scene;
-
}
-
-
boolCMyFirstScene::init()
-
{
-
if(!CCLayer::init())
-
{
-
returnfalse;
-
}
-
-
-
auto label =LabelTTF::create("New Scene","Arial",24);
-
-
// position the label on the center of the screen
-
label->setPosition(Point(200,300));
-
-
// add the label as a child to this layer
-
this->addChild(label,1);
-
// do something
-
returntrue;
-
}
-
#ifndef __linker__CMyFirstScene__
-
#define __linker__CMyFirstScene__
-
-
#include"cocos2d.h"
-
-
-
classCMyFirstScene:public cocos2d::CCLayer
-
{
-
public:
-
static cocos2d::Scene* createScene();
-
-
// 初始化
-
virtualbool init();
-
-
CREATE_FUNC(CMyFirstScene);
-
};
-
-
-
#endif/* defined(__linker__CMyFirstScene__) */
-
voidHelloWorld::imageMenuCallback(Object* pSender)
-
{
-
CCLog("ImageMenu");
-
-
CCTransitionScene* transiton=CCTransitionProgressRadialCW::create(1.2f,CMyFirstScene::createScene());
-
-
CCDirector::sharedDirector()->replaceScene(transiton);
-
-
-
}