Node之间的关系:

场景AppDelegate.cpp又要由导演去调用然后进行表演:

    // create a scene. it's an autorelease object
auto scene = HelloWorld::createScene(); // run
director->runWithScene(scene);

这里层里面的场景HelloWorldScene.cpp里面的内容:

#include "HelloWorldScene.h"

USING_NS_CC;

Scene* HelloWorld::createScene()
{
// 'scene' is an autorelease object
auto scene = Scene::create(); // 'layer' is an autorelease object
auto layer = HelloWorld::create(); // add layer as a child to scene
scene->addChild(layer); // return the scene
return scene;
} // on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
} Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin(); /////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
//每一个addChild会创建出一个添加的层
// add a "close" icon to exit the progress. it's an autorelease object
auto closeItem = MenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/ ,
origin.y + closeItem->getContentSize().height/)); // create menu, it's an autorelease object
auto menu = Menu::create(closeItem, NULL);
menu->setPosition(Vec2::ZERO);
this->addChild(menu, ); /////////////////////////////
// 3. add your codes below... // add a label shows "Hello World"
// create and initialize a label auto label = Label::createWithTTF("Hello sunzhiyan", "fonts/arial.ttf", ); // position the label on the center of the screen
label->setPosition(Vec2(origin.x + visibleSize.width/,
origin.y + visibleSize.height - label->getContentSize().height)); // add the label as a child to this layer
this->addChild(label, ); auto label1= Label::createWithTTF("", "fonts/arial.ttf", ); // position the label on the center of the screen
label1->setPosition(Vec2(origin.x + visibleSize.width / ,
origin.y + visibleSize.height - label1->getContentSize().height)); // add the label as a child to this layer
this->addChild(label1, ); //创建一个精灵
auto sprite = Sprite::create("sun.jpg"); //设置精灵的显示位置
sprite->setPosition(Vec2(visibleSize.width/ + origin.x, visibleSize.height/ + origin.y)); // 将精灵添加到层里面
this->addChild(sprite, ); return true;
} void HelloWorld::menuCloseCallback(Ref* pSender)
{
Director::getInstance()->end(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit();
#endif
}

cocos2dx 的Hello world的简单分析的更多相关文章

  1. cocos2dx骨骼动画Armature源码分析(一)

    源码分析一body { font-family: Helvetica, arial, sans-serif; font-size: 14px; line-height: 1.6; padding-to ...

  2. 简单分析JavaScript中的面向对象

    初学JavaScript的时候有人会认为JavaScript不是一门面向对象的语言,因为JS是没有类的概念的,但是这并不代表JavaScript没有对象的存在,而且JavaScript也提供了其它的方 ...

  3. CSipSimple 简单分析

    简介 CSipSimple是一款可以在android手机上使用的支持sip的网络电话软件,可以在上面设置使用callda网络电话.连接使用方式最好是使用wifi,或者3g这样上网速度快,打起电话来效果 ...

  4. C#中异常:“The type initializer to throw an exception(类型初始值设定项引发异常)”的简单分析与解决方法

    对于C#中异常:“The type initializer to throw an exception(类型初始值设定项引发异常)”的简单分析,目前本人分析两种情况,如下: 情况一: 借鉴麒麟.NET ...

  5. 透过byte数组简单分析Java序列化、Kryo、ProtoBuf序列化

    序列化在高性能网络编程.分布式系统开发中是举足轻重的之前有用过Java序列化.ProtocolBuffer等,在这篇文章这里中简单分析序列化后的byte数组观察各种序列化的差异与性能,这里主要分析Ja ...

  6. 简单分析Java的HashMap.entrySet()的实现

    关于Java的HashMap.entrySet(),文档是这样描述的:这个方法返回一个Set,这个Set是HashMap的视图,对Map的操作会在Set上反映出来,反过来也是.原文是 Returns ...

  7. Ffmpeg解析media容器过程/ ffmpeg 源代码简单分析 : av_read_frame()

    ffmpeg 源代码简单分析 : av_read_frame() http://blog.csdn.net/leixiaohua1020/article/details/12678577 ffmpeg ...

  8. FFmpeg的HEVC解码器源码简单分析:解析器(Parser)部分

    ===================================================== HEVC源码分析文章列表: [解码 -libavcodec HEVC 解码器] FFmpeg ...

  9. FFmpeg资料来源简单分析:libswscale的sws_getContext()

    ===================================================== FFmpeg库函数的源代码的分析文章: [骨架] FFmpeg源码结构图 - 解码 FFmp ...

随机推荐

  1. cademy的Java习题做后感

    在cademy各种语言的hello world也做了不少,好像都差不多,先是数据类型,然后条件语句,之后面向对象,再上几个特殊对象. 以前都没有做笔记,导致ruby做完就忘光了,这次好歹写点什么,比如 ...

  2. PHP+MYSQL实现输出打印数据库表结构和输出表内容

    效果图1 <form id="form1" name="form1" action="2.php" method="get& ...

  3. hadoop2.0 eclipse 源码编译

    在eclipse下编译hadoop2.0源码 http://www.cnblogs.com/meibenjin/archive/2013/07/05/3172889.html hadoop cdh4编 ...

  4. Android sqlite数据库存取图片信息

    Android sqlite数据库存取图片信息 存储图片:bitmap private byte[] getIconData(Bitmap bitmap){ int size = bitmap.get ...

  5. 从 mian 函数开始一步一步分析 nginx 执行流程(四)

    如不做特殊说明,本博客所使用的 nginx 源码版本是 1.0.14,[] 中是代码所在的文件! 这一节我们分析ngx_worker_process_cycle(),该函数代码比较少,因为它通过调用函 ...

  6. [LeetCode#116]Fraction to Recurring Decimal

    Problem: Given two integers representing the numerator and denominator of a fraction, return the fra ...

  7. Java基础之String,StringBuilder,StringBuffer

    在创建字符串的时候总是习惯性的使用String str = "...";,str = str+"abcd";也有听说过StringBuffer,StringBu ...

  8. Socket Class中文解释

    Socket 类 .NET Framework 4.6 and 4.5 实现 Berkeley 套接字接口. 继承层次结构   System.Object   System.Net.Sockets.S ...

  9. Delphi中WideString类型如何转化成String类型

    var wstr:WideString; str:string; begin str:=WideCharToString(PWideChar(wstr)); end;

  10. HDU --- 4006

    The kth great number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Oth ...