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. MyBatis学习 之 二、SQL语句映射文件(2)增删改查、参数、缓存

    目录(?)[-] 二SQL语句映射文件2增删改查参数缓存 select insert updatedelete sql parameters 基本类型参数 Java实体类型参数 Map参数 多参数的实 ...

  2. MyBatis association的两种形式——MyBatis学习笔记之四

    一.嵌套的resultMap 这 种方法本质上就是上篇博文介绍的方法,只是把教师实体映射从association元素中提取出来,用一个resultMap元素表示.然后 association元素再引用 ...

  3. C语言的代码内存布局

    由以下3个部分组成: 1)BSS 段 BSS段(bss segment)通常是指用来存放程序中未初始化的全局变量的一块内存区域.BSS是英文Block Started by Symbol的简称.BSS ...

  4. MFC最大化显示任务栏

    今天2016-07-23   13:26:24又来处理最大化时,窗口任务栏隐藏的bug. 前面已经用了 MINMAXINFO的结构体: typedef struct { POINT ptReserve ...

  5. Tkinter教程之Scale篇

    本文转载自:http://blog.csdn.net/jcodeer/article/details/1811313 '''Tkinter教程之Scale篇'''#Scale为输出限定范围的数字区间, ...

  6. LeetCode 232 Implement Queue using Stacks

    Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of ...

  7. LeetCode 234 Palindrome Linked List

    Given a singly linked list, determine if it is a palindrome. 思路: 回文结构从后向前遍历与从前向后遍历的结果是相同的,可以利用一个栈的结构 ...

  8. nginx配置pathinfo支持,最佳方案 - chunyu

    〇. 前言 pathinfo有两个,1 pathinfo()函数,2 $_SERVER['PATH_INFO'].pathinfo()是php的库函数,原生支持不需要nginx配置,$_SERVER[ ...

  9. Protocol Buffers编码详解,例子,图解

    Protocol Buffers编码详解,例子,图解 本文不是让你掌握protobuf的使用,而是以超级细致的例子的方式分析protobuf的编码设计.通过此文你可以了解protobuf的数据压缩能力 ...

  10. 【转】 Nginx系列(一)--nginx是什么?

    原博文出于:http://blog.csdn.net/liutengteng130/article/details/46700939  感谢! 一.介绍 Nginx是一个高性能的HTTP和反向代理服务 ...