资源简介
官方提供了Cocos2dx的第三方库,但是采用的是2.x的接口,3.x下面依然是可以使用的,不过在这添加了采用3.x接口封装的方法
代码片段和文件信息
//
// GB2ShapeCache-x.cpp
//
// Loads physics sprites created with http://www.PhysicsEditor.de
// To be used with cocos2d-x
//
// Generic Shape Cache for box2d
//
// Created by Thomas Broquist
//
// http://www.PhysicsEditor.de
// http://texturepacker.com
// http://www.code-and-web.de
//
// All rights reserved.
//
// Permission is hereby granted free of charge to any person obtaining a copy
// of this software and associated documentation files (the “Software“) to deal
// in the Software without restriction including without limitation the rights
// to use copy modify merge publish distribute sublicense and/or sell
// copies of the Software and to permit persons to whom the Software is
// furnished to do so subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND EXPRESS OR
// IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER
// LIABILITY WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING FROM
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#include “GB2ShapeCache-x.h“
#include “Box2D/Box2D.h“
using namespace cocos2d;
/**
* Internal class to hold the fixtures
*/
class FixtureDef {
public:
FixtureDef()
: next(NULL) {}
~FixtureDef() {
delete next;
delete fixture.shape;
}
FixtureDef *next;
b2FixtureDef fixture;
int callbackData;
};
class BodyDef {
public:
BodyDef()
: fixtures(NULL) {}
~BodyDef() {
if (fixtures)
delete fixtures;
}
FixtureDef *fixtures;
Vec2 anchorPoint;
};
static GB2ShapeCache *_sharedGB2ShapeCache = NULL;
GB2ShapeCache* GB2ShapeCache::sharedGB2ShapeCache(void) {
if (!_sharedGB2ShapeCache) {
_sharedGB2ShapeCache = new GB2ShapeCache();
_sharedGB2ShapeCache->init();
}
return _sharedGB2ShapeCache;
}
bool GB2ShapeCache::init() {
return true;
}
void GB2ShapeCache::reset() {
std::map::iterator iter;
for (iter = shapeobjects.begin() ; iter != shapeobjects.end() ; ++iter) {
delete iter->second;
}
shapeobjects.clear();
}
void GB2ShapeCache::addFixturesToBody(b2Body *body const std::string &shape) {
std::map::iterator pos = shapeobjects.find(shape);
assert(pos != shapeobjects.end());
BodyDef *so = (*pos).second;
FixtureDef *fix = so->fixtures;
while (fix) {
body->CreateFixture(&fix->fixture);
fix = fix->next;
}
}
cocos2d::Vec2 GB2ShapeCache::anchorPointForShape(const std::string &shape)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2124 2017-07-14 13:13 GB2ShapeCache-x.h
文件 7889 2017-07-04 15:25 GLES-Render.cpp
文件 2177 2016-06-23 15:42 GLES-Render.h
文件 12011 2017-07-17 09:52 GB2ShapeCache-x.cpp
- 上一篇:verilog 带符号乘法器代码
- 下一篇:用汇编语言实现的电子时钟
相关资源
- MPEG4中文标准.pdf
-
OfficeOpenxm
lCrypto - YUV420在qt5下显示
- 2020年最新深圳地铁线+地铁站点矢量
- CAS-PEAL-R1 人脸数据库
- glut工具库
- USB type C 16Pin
- chopper.exe
- PerconaXtraBackup-8.0.11.pdf.zip
- 计算机图形学 交互实体模型
- openmv_windows驱动.zip
- number.zip
- 机器视觉霍夫圆检测识别木材死节O
- 天池-student预测数据集
- OPENGL读取显示obj模型_VS2010
- PEview.exe
- eXeScope 最好用的版本
- speexdec mac 可执行程序
-
Openla
yers 简单6 - HPE_ProLiant_ML310e_Gen8_前置开关及灯线线
- JPEG解码,可以移植到STM32中
- intel_ocl_caps_basic_win.zip
- 运用Opengl和C实现一个人体面部的三维
- HP LoadRunner12.55 +Web ToursHPE LoadRunner 12
- 图像的预处理灰度图、二值化、字符
- opengl实现分形山脉
- BlendShape表情镜像
- linux下用freetype2显示汉字
- Hypertrm(超级终端)
- 开源处理器OpenMIPS模块连接关系图
评论
共有 条评论