cocos2dx and c++ 的小坑
来源:互联网 发布:数学符号输入软件 编辑:程序博客网 时间:2024/05/29 18:43
- char[] 大小
char[x]
当时没注意这个 因为需求中 这里需要格式化的只有1、2、3、4这几种情况都是大小为1的 结果出现如下错误
原因应该是 只能容下 x-1 个字符 必须保留最后一个字符作为结尾判断 否则不知道如何释放
Run-Time Check Failure #2 - Stack around the variable ‘str’ was corrupted. int[] 赋值
最容易想到的赋值方式却出问题了要用以下的赋值方式
memcpy(mMapView, b.barriers, sizeof(b.barriers));cocos2d-x调用scheduleUpdate()不执行update()方法的解决办法
网上搜出来的
但是去掉方法这样肯定就不好了 如果你舍不得去掉onEnter方法 我们可以在子类中调用父类的对应方法 比如我的情况在自己实现的onEnter里面调用下Layer::onEnter();
这个其实很容易想到的 至少ios开发中太多这种了- int string 转换 cocos2dx适用
Value(int).asString();// 函数里面调用的是 std::stringstream ret;char str[255];sprintf(str, "***%d**", index); 这种 太麻烦了 好累
- 函数赋值空
std::function<void(void)> //赋值空 应该用 nullptr
- 动画暂停到某一帧
//action->setCurrentFrame(10 * n);//这个看起来很像但是不行action->gotoFrameAndPause(10 * n);
- boolean bool
不要使用boolean在编译android的时候报错 - string
#include <string> //#include <string.h> 不要使用后者 (我当时的情况就不能用后者 android编译出错)
- android解析
来源于互联网bool AppDelegate::isFileExist(const char* pFileName){ if (!pFileName) return false; std::string filePath = FileUtils::getInstance()->getWritablePath(); filePath += pFileName; FILE *fp = fopen(filePath.c_str(), "r"); if (fp) { fclose(fp); return true; } return false;}void AppDelegate::copyData(const char* pFileName){ if (isFileExist(pFileName)) { return; } std::string strPath = FileUtils::getInstance()->fullPathForFilename(pFileName); ssize_t len = 0; unsigned char *data = NULL; data = FileUtils::getInstance()->getFileData(strPath.c_str(), "r", &len); std::string destPath = FileUtils::getInstance()->getWritablePath(); destPath += pFileName; FILE *fp = fopen(destPath.c_str(), "w+"); fwrite(data, sizeof(char), len, fp); fclose(fp); delete[]data; data = NULL;}
0 0
- cocos2dx and c++ 的小坑
- cocos2dx and c++ 的小知识点
- C 的各种指针 and 小细节。
- COCOS2DX的场景切换and动作
- cocos2dx加载texturepacker遇到的小麻烦
- cocos2dx 3.13 tableview cell 的小问题
- cocos2dx lua 学习小坑整理
- cocos2dx的那些坑
- cocos2dx遇到的坑
- cocos2dx游戏-可爱的小精灵的各种用法大全
- cocos2dx移植小问题
- cocos2dx-小技巧记录
- Cocos2dx-俄罗斯方块小项目
- cocos2dx 一个小控件
- Cocos2dx 小技巧(三)Label的换行
- Cocos2dx 小技巧(九)现成的粒子特效
- Cocos2dx 小技巧(八) visit的逆袭
- Cocos2dx 小技巧(八) visit的逆袭
- 类和数据抽象
- 面向对象编程与泛型编程
- 高级主题
- VC 使用combox
- svn check in ,check out, import, export
- cocos2dx and c++ 的小坑
- 常用DIV+CSS命名大全集合
- Xcode出现may cause a leak的解决
- PHP优化之mysql结构
- android第一个用户进程Init进程
- *LeetCode-Kth Smallest Element in a BST
- mac .bash_profile etc...
- C++ new和delete重载
- android中tesseract-ocr的介绍