i uploaded it to my github
https://github.com/meiry/PhysicsEditor~~*cocos2d-x-ver3-loader
i noticed the helper class’s are for version 2 so i updated it to use version cocos2d-x-3.0alpha1
i hope you will find it useful
GB2ShapeCache-x.cpp
<pre>
//
// 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 , 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”
#include “CCNS.h”
//using namespace cocos2d;
USING_NS_CC;
/**
** Internal class to hold the fixtures
/
class FixtureDef {
public:
FixtureDef
: next
FixtureDefnext;
b2FixtureDef fixture;
int callbackData;
};
class BodyDef {
public:
BodyDef
: fixtures
FixtureDef fixtures;
CCPoint anchorPoint;
};
static GB2ShapeCachesharedGB2ShapeCache = NULL;
GB2ShapeCache* GB2ShapeCache::sharedGB2ShapeCache {
if {
*sharedGB2ShapeCache = new GB2ShapeCache;
*sharedGB2ShapeCache~~>init();
}
return _sharedGB2ShapeCache;
}
bool GB2ShapeCache::init() {
return true;
}
void GB2ShapeCache::reset() {
std::map<std::string, BodyDef *>::iterator iter;
for (iter = shapeObjects.begin() ; iter != shapeObjects.end() ; ++iter) {
delete iter~~>second;
}
shapeObjects.clear;
}
void GB2ShapeCache::addFixturesToBody {
std::map<std::string, BodyDef *>::iterator pos = shapeObjects.find;
assert);
BodyDef so = .second;
FixtureDeffix = so~~>fixtures;
while (fix) {
body~~>CreateFixture;
fix = fix~~>next;
}
}
cocos2d::CCPoint GB2ShapeCache::anchorPointForShape(const std::string &shape) {
std::map<std::string, BodyDef *>::iterator pos = shapeObjects.find(shape);
assert(pos != shapeObjects.end());
BodyDef bd = .second;
return bd~~>anchorPoint;
}
//typedef Dictionary ObjectDict;
void GB2ShapeCache::addShapesWithFile {
//const char fullName = CCFileUtils::fullPathFromRelativePath);
std::string fullName = FileUtils::getInstance~~>fullPathForFilename;
//ObjectDict dict = CCFileUtils::dictionaryWithContentsOfFile;
Dictionarydict = Dictionary::createWithContentsOfFile);
CCAssert; // not triggered~~ cocos2dx delivers empty dict if non was found
CCAssert != 0, “plist file empty or not existing”);
DictionarymetadataDict = dict~~>objectForKey;
int format = static_cast<CCString *>)>intValue;>floatValue;
ptmRatio = static_cast<CCString *>)
CCAssert;
DictionarybodyDict = (Dictionary **)dict~~>objectForKey;
b2Vec2 vertices[b2\_maxPolygonVertices];
std::string bodyName;
Dictionary bodyData;
DictElement pElement = NULL;
CCDICT_FOREACH
{
Dictionary* bodyData = pElement~~>getObject;
bodyName = pElement~~>getStrKey;
BodyDef bodyDef = new BodyDef;
const char pszContent = static_cast<String >)>getCString;>anchorPoint = PointFromString;
bodyDef
Array **fixtureList = );
FixtureDef***nextFixtureDef = &;
Object** pObj = NULL;
CCARRAY_FOREACH
{
Dictionary *fixtureData = static_cast<Dictionary>;
b2FixtureDef basicData;
basicData.filter.categoryBits = static_cast<CCString *>)>intValue;>intValue;
basicData.filter.maskBits = static_cast<CCString *>)
basicData.filter.groupIndex = static_cast<CCString *>)>intValue;>floatValue;
basicData.friction = static_cast<CCString *>)
basicData.density = static_cast<CCString *>)>floatValue;>floatValue;
basicData.restitution = static_cast<CCString *>)
basicData.isSensor = static_cast<CCString *>)>intValue;>intValue;
CCString **cb = static_cast<CCString *>);
int callbackData = 0;
if
callbackData = cb
std::string fixtureType = static_cast<CCString *>)~~>getCString;
if {
Array**polygonsArray = );
//for ; iter != polygonsArray~~>end; ++iter) {
Object** pObjPolygons = NULL;
CCARRAY_FOREACH
{
FixtureDef fix = new FixtureDef;
fix~~>fixture = basicData; // copy basic data
fix~~>callbackData = callbackData;
b2PolygonShapepolyshape = new b2PolygonShape;
int vindex = 0;
Array *polygonArray = static_cast<Array>;
assert <= b2_maxPolygonVertices);
//for ; piter != polygonArray~~>end; ++piter) {
Object* pObjPolygon = NULL;
CCARRAY_FOREACH
{
std::string polygonValue = static_cast<CCString *>>getCString;>Set;
CCPoint offset = PointFromString);
vertices[vindex].x = ;
vertices[vindex].y = ;
vindex++;
}
polyshape
fix~~>fixture.shape = polyshape;
// create a list
nextFixtureDef = fix;
nextFixtureDef = &;
}
} else if {
FixtureDef fix = new FixtureDef;
fix~~>fixture = basicData; // copy basic data
fix~~>callbackData = callbackData;
DictionarycircleData = fixtureData~~>objectForKey;
b2CircleShapecircleShape = new b2CircleShape();
circleShape~~>m_radius = static_cast<CCString *>)>floatValue() / ptmRatio;>objectForKey)
CCPoint p = PointFromString(static_cast<CCString *>(circleData>getCString());>m_p = b2Vec2;
circleShape
fix~~>fixture.shape = circleShape;
// create a list
**nextFixtureDef = fix;
nextFixtureDef = &;
} else {
CCAssert;
}
// add the body element to the hash
shapeObjects[bodyName] = bodyDef;
}
}
}
</pre>
**GB2ShapeCache-x.h*
//
// 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.
//
#ifndef GB2ShapeCache_x_h
#define GB2ShapeCache_x_h
#include "cocos2d.h"
//using namespace cocos2d;
USING_NS_CC;
class BodyDef;
class b2Body;
namespace cocos2d {
class GB2ShapeCache {
public:
// Static interface
static GB2ShapeCache* sharedGB2ShapeCache(void);
public:
bool init();
void addShapesWithFile(const std::string &plist);
void addFixturesToBody(b2Body *body, const std::string &shape);
cocos2d::CCPoint anchorPointForShape(const std::string &shape);
void reset();
float getPtmRatio() { return ptmRatio; }
~GB2ShapeCache() {}
private:
std::map shapeObjects;
GB2ShapeCache(void) {}
float ptmRatio;
};
}
#endif