摘要: Widget only supports Widgets as children https://www.baidu.com/s?wd=Widget%20only%20supports%20Widgets%20as%20children&rsv_spt=1&rsv_iqid=0xc473b15e00 阅读全文
posted @ 2017-01-09 11:28 feizuzu 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 读取.tmx地图 m_GameMap = CCTMXTiledMap::create("map1.tmx"); this->addChild(m_GameMap,1);读取对象数组bool bFlag = false;//获取对象层 TMXObjectGroup *group = getGameMap()->objectGroupNamed("coll");//通过对象名获取该对象层对象 a... 阅读全文
posted @ 2017-01-09 11:27 feizuzu 阅读(550) 评论(0) 推荐(0) 编辑
摘要: cocos new hello -p com.xx.xx -l cpp -d d:/(创建)cocos compile -p android --ap 20(根据版本不同输入不同的文字不然报错)来自为知笔记(Wiz) 阅读全文
posted @ 2017-01-09 11:27 feizuzu 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 工程右键Properties选择 java build path在projects添加工程,然后在order and export勾上工程,点击ok然后选择Android,在library下add需要的工程,点击ok注意:添加的工程中libs含有armeabi和armeabi-v7a等不同平台,只保留armeabi,其他平台删掉来自为知笔记(Wiz) 阅读全文
posted @ 2017-01-09 11:27 feizuzu 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 第一种是采用函数回调,主要是用于MenuItem[cpp] view plaincopy// a selector callback void menuCloseCallback(Object* pSender); auto closeItem = MenuItemImage::create("CloseNormal.png","CloseSelected.png", ... 阅读全文
posted @ 2017-01-09 11:26 feizuzu 阅读(164) 评论(0) 推荐(0) 编辑
摘要: http://my.oschina.net/u/555701/blog/219844c++ 11 基础 : std::function 类模版 std::function是一种通用、多态的函数封装。std::function的实例可以对任何可以调用的目标进行存储、复制、和调用操作,这些目标包括函数、lambda表达式、绑定表达式、以及其它函数对象等。用法示例:①保存自由函数vo... 阅读全文
posted @ 2017-01-09 11:26 feizuzu 阅读(299) 评论(0) 推荐(0) 编辑
摘要: CC_SYNTHESIZE相当于set,get方法,且不需要定义例CC_SYNTHESIZE(cocos2d::TMXTiledMap*, gameMap, GameMap); CC_SYNTHESIZE(MPLAYER_STATE, mPlayerState, MPlayerState);CC_SYNTHESIZE(float, xSpeed, XSpeed); CC_SYNTHES... 阅读全文
posted @ 2017-01-09 11:25 feizuzu 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 场景A切换到场景B,有切换特效调用顺序如下:(AAABABABA)A:构造函数A:onEnterA:onEnterTransitionDidFinishB:构造函数A:onExitTransitionDidStartB:onEnterA:onExitB:onEnterTransitionDidFinishA:析构函数场景A切换到场景B,无切换特效调用顺序如下:(AAABAABBA)A:构造函数A:... 阅读全文
posted @ 2017-01-09 11:24 feizuzu 阅读(170) 评论(0) 推荐(0) 编辑
摘要: #include//structstruct GOLD_STRUCT{ Sprite * goldspSprite; int goldValue;};//声明一个GOLD_STRUCT的vectorCC_SYNTHESIZE(std::vector, goldVector, GoldVector);//将对象放入到vector容器中void HelloWorld::initdaoju... 阅读全文
posted @ 2017-01-09 11:24 feizuzu 阅读(291) 评论(0) 推荐(0) 编辑
摘要: auto background = Sprite::create("background.png"); background->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2)); Size backgroundSize = background->getContentSize(); ScrollVie... 阅读全文
posted @ 2017-01-09 11:23 feizuzu 阅读(312) 评论(0) 推荐(0) 编辑
摘要: ListView * listview = ListView::create(); //设置listview方向 垂直 listview->setDirection(ScrollView::Direction::VERTICAL); listview->setBackGroundImage("ccc.png"); //背景做9宫格填充 listview->setBac... 阅读全文
posted @ 2017-01-09 11:23 feizuzu 阅读(563) 评论(0) 推荐(0) 编辑
摘要: //获取精灵帧缓存的单例对象auto spriteFrameCache = SpriteFrameCache::getInstance();//从plist文件添加多个精灵帧spriteFrameCache->addSpriteFrameWithFile("XX.plist");//根据图片名称创建一个精灵帧auto sprite1Frame =spriteFrameCache->getSpri... 阅读全文
posted @ 2017-01-09 11:23 feizuzu 阅读(1342) 评论(0) 推荐(0) 编辑
摘要: auto pageview = PageView::create(); pageview->setContentSize(Size(480.0f, 320.0f)); pageview->setPosition(Vec2((visibleSize.width - pageview->getContentSize().width) / 2.0f, (visibleSize.hei... 阅读全文
posted @ 2017-01-09 11:23 feizuzu 阅读(416) 评论(0) 推荐(0) 编辑
摘要: #include"ui/CocosGUI.h"using namespace ui; Text* displayValudLabel = Text::create("轻易动滑块","Marker Felt.ttf", 48); displayValudLabel->setPosition(Vec2()); this->addChild(displayValudLabel); ... 阅读全文
posted @ 2017-01-09 11:22 feizuzu 阅读(160) 评论(0) 推荐(0) 编辑
摘要: #include"ui/CocosGUI.h"using namespace ui;Layout *layout = Layout::create(); //设置布局类型为平面相对布局 layout->setLayoutType(LayoutType::RELATIVE); //设置大小 layout->setContentSize(Size(280, 150)); ... 阅读全文
posted @ 2017-01-09 11:22 feizuzu 阅读(346) 评论(0) 推荐(0) 编辑
摘要: auto start = MenuItemFont::create("ON");auto stop =MenuItemFont::create("OFF");auto toggle = MenuItemToggle::createWithCallback(CC_CALLBACK_1(HellWord::menuONorOFFCallback,this),start,stop,NULL);toggl... 阅读全文
posted @ 2017-01-09 11:20 feizuzu 阅读(932) 评论(0) 推荐(0) 编辑
摘要: //预加载音乐和音效SimpleAudioEngine::getInstance()->preloadBackgroundMusic(MUSIC_FILE);SimpleAudioEngine::getInstance()->preloadEffect(EFFECT);//播放背景音乐SimpleAudioEngine::getInstance()->playBackgroundMusic(MUS... 阅读全文
posted @ 2017-01-09 11:19 feizuzu 阅读(365) 评论(0) 推荐(0) 编辑
摘要: CCDictionary *strings = CCDictionary::createWithContentsOfFile("tips2.xml"); const char *hello = ((CCString*)strings->valueForKey("tp1"))->m_sString.c_str(); CCLabelTTF *labelHello = CCLabelTTF... 阅读全文
posted @ 2017-01-09 11:18 feizuzu 阅读(269) 评论(0) 推荐(0) 编辑
摘要: void MPlayer::setMapPointByMplayer(){ Size visableSize = Director::getInstance()->getVisibleSize(); Size mapTileNum = getGameMap()->getMapSize(); Size tiledSize = getGameMap()->getTileSize();... 阅读全文
posted @ 2017-01-09 11:18 feizuzu 阅读(551) 评论(0) 推荐(0) 编辑
摘要: 在做数据转换时,最好包含以下头文件#include #include #include #include USING_NS_CC;using namespace std;在cocos2d-x中,也有一个格式刷:CCString(数据转换常常找她做中间人),那么我们要转换类型,可先将起始数据类型刷成CCString然后再转成目的数据类型,这个方法比较方便且实用。 //int 转 CCstringi... 阅读全文
posted @ 2017-01-09 11:17 feizuzu 阅读(198) 评论(0) 推荐(0) 编辑