|
1
|
|
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
#ifndef __GB2ShapeCache__LAYER_H__
|
|
10
|
#define __GB2ShapeCache__LAYER_H__
|
|
11
|
|
|
12
|
#include "cocos2d.h"
|
|
13
|
|
|
14
|
class BodyDef;
|
|
15
|
class b2Body;
|
|
16
|
|
|
17
|
class GB2ShapeCache
|
|
18
|
{
|
|
19
|
public:
|
|
20
|
GB2ShapeCache();
|
|
21
|
|
|
22
|
~GB2ShapeCache();
|
|
23
|
|
|
24
|
static GB2ShapeCache* sharedShapeCache();
|
|
25
|
|
|
26
|
|
|
27
|
* Adds shapes to the shape cache
|
|
28
|
* @param plist name of the plist file to load
|
|
29
|
*/
|
|
30
|
void addShapesWithFile(const char* plist);
|
|
31
|
|
|
32
|
|
|
33
|
* Adds fixture data to a body
|
|
34
|
* @param body body to add the fixture to
|
|
35
|
* @param shape name of the shape
|
|
36
|
*/
|
|
37
|
void addFixturesToBody(b2Body* body ,const char* shapeName);
|
|
38
|
|
|
39
|
|
|
40
|
* Returns the anchor point of the given sprite
|
|
41
|
* @param shape name of the shape to get the anchorpoint for
|
|
42
|
* @return anchorpoint
|
|
43
|
*/
|
|
44
|
cocos2d::CCPoint anchorPointForShape(const char* shapeName);
|
|
45
|
|
|
46
|
|
|
47
|
* Returns the ptm ratio
|
|
48
|
*/
|
|
49
|
CC_SYNTHESIZE_READONLY(float, m_ptmRatio, PtmRatio)
|
|
50
|
|
|
51
|
private:
|
|
52
|
const char* valueForKey(const char *key, cocos2d::CCDictionary<std::string, cocos2d::CCObject*> *dict);
|
|
53
|
|
|
54
|
cocos2d::CCMutableDictionary<std::string, BodyDef*>* m_shapeObjects;
|
|
55
|
};
|
|
56
|
|
|
57
|
#endif
|