1.创建项目后环境配置:

附加文件夹:加入

$(EngineRoot)

$(EngineRoot)cocos

$(EngineRoot)cocos\editor-support

$(EngineRoot)build\Debug.win32

..\proj.win32

通用属性加入

(先从 cocos2d-x-3.0rc0 中 extensions   cocos\editor-support   cocos\ui 加入进去)

libcocosstudio

libExtensions

libGUI

链接器 附加依赖项:

libGUI.lib

libCocosStudio.lib

libExtensions.lib

头文件的加入:

这些都放在头文件中

#include "cocos2d.h"

#include "ui\CocosGUI.h"

#include "cocos-ext.h"

#include "ui\UIButton.h"

#include "cocostudio\CocoStudio.h"

#include "editor-support\cocostudio\CCSGUIReader.h"

#include <iostream>

using namespace std;

using namespace cocos2d;

using namespace cocostudio;

using namespace ui;

在init中就能够将外部建好的场景倒入进来

auto m_layout = cocostudio::GUIReader::getInstance()->widgetFromJsonFile("login_ui\\NewUI_1.ExportJson");

 this->addChild(m_layout);

场景中的button和代码链接UI_BUTTON_LOGIN是在外部场景中的tag值

Button* startBtn = dynamic_cast<Button*>(m_layout->getChildByTag(UI_BUTTON_LOGIN)); 


 startBtn->addTouchEventListener(this,toucheventselector(HelloWorld::touchButton));

场景中的中文字符的显示:

wstring HelloWorld::charToWstring(const char* c) 



 wstring ws; 

 int len = MultiByteToWideChar(CP_ACP,0,c,strlen(c),NULL,0); 

 wchar_t* m_wchar=new wchar_t[len+1]; 

 MultiByteToWideChar(CP_ACP,0,c,strlen(c),m_wchar,len); 

 m_wchar[len]='\0';

ws.append(m_wchar); 

 return ws; 

}

inline std::string WideByte2UTF8(const wstring& text)

{

int asciisize = ::WideCharToMultiByte(CP_UTF8, 0, text.c_str(), text.size(), NULL, 0, NULL, NULL);

if (asciisize == ERROR_NO_UNICODE_TRANSLATION ||

asciisize == 0)

{

return string();

}

char* resultstring = new char[asciisize];

int convresult = ::WideCharToMultiByte(CP_UTF8, 0, text.c_str(), text.size(), resultstring, asciisize, NULL, NULL);

if (convresult != asciisize)

{

return string();

}

std::string buffer(resultstring, convresult);

delete[] resultstring;

return buffer;

}

button切换场景

void HelloWorld::touchButton(Ref* obj,TouchEventType eventype)

{

Scene* pScene = ui_login_tag::createScene();

 Director::sharedDirector()->replaceScene(pScene);

}

加入动画:

ArmatureDataManager::getInstance()->addArmatureFileInfo("MyAnimation.ExportJson");

 Armature* armature = Armature::create("MyAnimation");

 armature->setTag(AM_MYANIMATION);

armature->setPosition(Point(visibleSize.width/2,visibleSize.height/2));

 

 this->addChild(armature);

button播放动画

auto armature = (Armature*)getChildByTag(AM_MYANIMATION);

 switch (type)

 {

 case TouchEventType::TOUCH_EVENT_ENDED:

  if(tag == UI_BUTTON_BUTTON_PLAY1)

  {

   armature->getAnimation()->play("hit");

  }else if(tag == UI_BUTTON_BUTTON_PLAY2)

  {

   armature->getAnimation()->play("fall");

  }

  break;

 default:

  break;

 }

cocos2d(3.0)一些基础的东西的更多相关文章

  1. 如何在Cocos2D 1.0 中掩饰一个精灵(六)

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请告诉我,如果觉得不错请多多支持点赞.谢谢! hopy ;) 掩饰一个精灵:实现代码 打开HelloWorldLayer.m并 ...

  2. Cocos2D v2.0至v3.x简洁转换指南(三)

    Cocos2D 3.3中的注意事项 如果你在使用Cocos2D 3.3+(是SpriteBuilder 1.3+的一部分)你将不得不替分别的换所有存在的UITouch和UITouchEvent为CCT ...

  3. ASP.NET MVC 3.0 Controller基础

    ASP.NET MVC 3.0 Controller基础   1.Controller类与方法 Controller(控制器)是ASP.NET MVC的核心,负责处理浏览器请求,并作出响应.Cotro ...

  4. 如何在Cocos2D 1.0 中掩饰一个精灵(一)

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请告诉我,如果觉得不错请多多支持点赞.谢谢! hopy ;) 原帖来自Ray Wunderlich写的精彩的文章 How To ...

  5. Cocos2D v2.0至v3.x简洁转换指南(二)

    触摸处理 我们在稍后将完成Cocos2d 3.0中触摸处理的完整教程.而现在最重要的是知道如何去启用触摸处理在你的CCNode中: self.userInteractionEnabled = TRUE ...

  6. cocos2d 2.0和UIKit混合编程, Push CCDirector的时候出现黑屏的天坑

    症状 使用cocos2d 2.0和UIKit混合编程, 有一块用cocos2d编写的小程序, 将CCDirector push到一个UINavigationController里面. 虽然事先在后台初 ...

  7. 1.0 Android基础入门教程

    1.0 Android基础入门教程 分类 Android 基础入门教程 本教程于2015年7月开始撰写,耗时半年,总共148节,涵盖了Android基础入门的大部分知识,由于当时能力局限,虽已竭尽全力 ...

  8. 如何在Cocos2D 1.0 中掩饰一个精灵(五)

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请告诉我,如果觉得不错请多多支持点赞.谢谢! hopy ;) 掩饰和CCRenderTexture CCRenderTextu ...

  9. java用POI操作excel——随便写一下,最基础的东西

    前两天部门实施在做一个东西,需要把客户放在Excel中的数据导入到Oracle数据库中,我就想着直接写一个模板,必要的时候改一下实体类应该可以解放实施同事的双手,不过在实际写的过程中,还是碰到很多问题 ...

随机推荐

  1. 确实是非常实用的Ubuntu命令

    1 文件管理 # ls ls -a 列出当前目录下的所有文件,包括以.头的隐含文件 文件管理 # ls ls-l或ll 列出当前目录下文件的详细信息 文件管理 # pwd pwd查看当前所在目录的绝对 ...

  2. winfrom dataGridView 自定义分页实现

    Winfrom 基本处于忘光的阶段.先需要做个winfrom 的软件.然后自己扩展了DataGridView带分页的控件.废话不多说 上图先   现在一步步实现其效果. 1.添加用户控件 上图即可知道 ...

  3. SQL Server 2012安装时如何不安装自带的Visual Studio

    不安装以下两个:

  4. golang学习遭遇错误原因分析续

    7. error: reference to field ‘Printf’ in object which has no fields or methods f.Printf("%v&quo ...

  5. again

    建立一个IPC连接: net use \\192.168.0.5\ipc$ "123456" /u:administrator

  6. IOS 支付宝 SDK 申请

    https://b.alipay.com/order/productDetail.htm?productId=2013080604609654&tabId=4#ps-tabinfo-hash

  7. Motan:目录结构

    motan是由maven管理的,在最外层的pom.xml中可以看出这个项目有多个模块组成. <modules> <module>motan-core</module> ...

  8. Tkinter教程之Message篇

    本文转载自:http://blog.csdn.net/jcodeer/article/details/1811326 '''Tkinter教程之Message篇'''#Message也是用来显示文本的 ...

  9. A题进行时--浙大PAT 1011-1020

    #include<stdio.h> #include<string.h> int main(){ ]; ]; ]; ]; ]; int i; float sum; memset ...

  10. Hadoop上路-03_Hadoop JavaAPI

    一.Eclipse安装 1.下载解压 下载:http://www.eclipse.org/downloads/ 解压:SHELL$ sudo tar -zxvf eclipse.tar.gz 2.快捷 ...