Cocos2d-x 101 encounter/directory
1. Installation and environment setup-xcode
2 Scenes, Director, Layers, Sprites
3. Create an image menu
4. Create a new scenario on HelloWorld
5. Add a sprite.
5.1 scale down sprite and display it completely
6 action, mobile sprite
3.0 Click Event, CCTouchDelegate has been disabled
8 use the touch event mobile genie
4. Create a new scenario on HelloWorld
Add new file
Name: CMyFirstScene,
Fill in the following content in the. CPP and. h files respectively:
//
// 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();
// Initialization
virtualbool init();
CREATE_FUNC(CMyFirstScene);
};
#endif/* defined(__linker__CMyFirstScene__) */
Add the following in the HelloWorld. cpp callback function:
voidHelloWorld::imageMenuCallback(Object* pSender)
{
CCLog("ImageMenu");
CCTransitionScene* transiton=CCTransitionProgressRadialCW::create(1.2f,CMyFirstScene::createScene());
CCDirector::sharedDirector()->replaceScene(transiton);
}