随笔分类 -  Cocos2d-x

摘要: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 阅读(117) 评论(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 阅读(581) 评论(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 阅读(230) 评论(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 阅读(337) 评论(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 阅读(212) 评论(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 阅读(192) 评论(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 阅读(306) 评论(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 阅读(582) 评论(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 阅读(437) 评论(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 阅读(326) 评论(0) 推荐(0)
摘要://获取精灵帧缓存的单例对象auto spriteFrameCache = SpriteFrameCache::getInstance();//从plist文件添加多个精灵帧spriteFrameCache->addSpriteFrameWithFile("XX.plist");//根据图片名称创建一个精灵帧auto sprite1Frame =spriteFrameCache->getSpri... 阅读全文
posted @ 2017-01-09 11:23 feizuzu 阅读(1368) 评论(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 阅读(181) 评论(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 阅读(372) 评论(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 阅读(960) 评论(0) 推荐(0)
摘要://预加载音乐和音效SimpleAudioEngine::getInstance()->preloadBackgroundMusic(MUSIC_FILE);SimpleAudioEngine::getInstance()->preloadEffect(EFFECT);//播放背景音乐SimpleAudioEngine::getInstance()->playBackgroundMusic(MUS... 阅读全文
posted @ 2017-01-09 11:19 feizuzu 阅读(408) 评论(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 阅读(570) 评论(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 阅读(296) 评论(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 阅读(221) 评论(0) 推荐(0)
摘要:bool WelcomeLayer::isHaveSaveFile()//判断存档是否存在{ if(!CCUserDefault::sharedUserDefault()->getBoolForKey("isHaveSaveFileXml"))//通过设置的bool型标志位判断,如果不存在 { CCUserDefault::sharedUserDefault()->set... 阅读全文
posted @ 2017-01-09 11:16 feizuzu 阅读(302) 评论(0) 推荐(0)
摘要://雪花效果schedule(schedule_selector(MainBoard::addSnowLight),0.2);void MainBoard::addSnowLight(float dt){ UIImageView* pSnow = UIImageView::create(); pSnow->loadTexture("GameUI/snow.png"); pSnow... 阅读全文
posted @ 2017-01-09 11:16 feizuzu 阅读(417) 评论(2) 推荐(0)