资源简介
官方提供了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 带符号乘法器代码
- 下一篇:用汇编语言实现的电子时钟
相关资源
- A Sequential Bundle Method for Solving a MPEC
- Concurrency in Go Tools and Techniques for Dev
- Narrow Hyper Imaginary Number and Generalized
- 《Windows PowerShell 4.0 for .NET Developers》
- Beginning STM32: Developing with FreeRTOS libo
- 中国1:400万基础地理数据
- CANopen使用手册_埃斯顿
- OpenGL参考手册
-
AN_BLE-SDKDH-C1_Teli
nk BLE SDK DeveloperHan - Diltiazem augmented pentobarbital-induced LORR
- 引力波是玻色-爱因斯坦凝聚物暗物质
- WPE三件套(WPE+CCP+E2G)冰枫修改版
- DXperienceUniversal 10.1.6(2010年8月13日版
- Qt Creator opengl实现四元数鼠标控制轨迹
- 使用OpenFileDialog打开文件对话框.rar
- Openssl给文件传输加密
- MP3文件ID3v2ID3v2APEv2标签读取
- OpenGL文档,api大全,可直接查询函数
- Speex手册中文版
- opengl轮廓字体源代码
- WinForm属性编辑 propertyGrid示例 仿wind
- MFC读三维模型obj文件
- PESQ C源代码
- 基于OpenCV的数字识别468815
- 使用opencv去掉二值化图像中黑色面积
- openssl 简介(中文)
- wpe源码1.2
- 利用OpenGL写毛笔字算法
- MFC中OpenGL面和体的绘制以及动画效果
- QT,JPEG解码源代码(已完成)
评论
共有 条评论