- 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 使用触摸事件移动 精灵
4 在HelloWorld上--建立新场景
加入新文件
命名为:CMyFirstScene,
.CPP和.h 文件分别填上下面内容
//
// CMyFirstScene.cpp
// linker
//
// Created by
HeJiasheng on 14-3-12.//
//
#include"CMyFirstScene.h"
USING_NS_CC;
Scene*CMyFirstScene::createScene()
{
//
‘scene‘ is an autorelease objectauto scene =Scene::create();
//
‘layer‘ is an autorelease objectauto layer =CMyFirstScene::create();
//
add layer as a child to scenescene->addChild(layer);
//
return the scenereturn scene;
}
boolCMyFirstScene::init()
{
if(!CCLayer::init())
{
returnfalse;
}
auto label =LabelTTF::create("New
Scene","Arial",24);//
position the label on the center of the screenlabel->setPosition(Point(200,300));
//
add the label as a child to this layerthis->addChild(label,1);
//
do somethingreturntrue;
}
#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__) */
在 HelloWorld.cpp 回调函数加入例如以下:
voidHelloWorld::imageMenuCallback(Object* pSender)
{
CCLog("ImageMenu");
CCTransitionScene* transiton=CCTransitionProgressRadialCW::create(1.2f,CMyFirstScene::createScene());
CCDirector::sharedDirector()->replaceScene(transiton);
}
时间: 2024-10-05 03:46:33