I'm using cocos2d and box2d.(iPhone SDK) If I want to import box2d I add this to the top of the file #import "Box2D.h" and then I rename my class to " .mm ". Now I have just a class without a ".m" file just a ".h" file.
It looks like that and if I import box2d it gives me many errors because box2d is c++ and normally i need to change it to ".mm" but i cant.
#import "Box2D.h"
// Defines individual types of messages that can be sent over the network. One type per packet.
typedef enum
{
kPacketTypeTime = 1,
kPacketTypePosition = 2,
kPacketTypeStartSignal = 3,
} EPacketTypes;
// Note: EPacketType type; must always be the first entry of every Packet struct
// The receiver will first assume the received data to be of type SBasePacket, so it can identify the actual packet by type.
typedef struct
{
EPacketTypes type;
} SBasePacket;
// the packet for transmitting a score variable
typedef struct
{
EPacketTypes type;
float time;
} STimePacket;
// packet to transmit a position
typedef struct
{
EPacketTypes type;
b2Vec2 position; //*******************************important**
float rotation;
} SPositionPacket;
// packet to transmit a start signal
typedef struct
{
EPacketTypes type;
BOOL startGame;
} SStartSignalPacket;
Why I want to do this? Look at the " * *important" in my code. I want to use b2Vec2.
Thank you very much for reading. Have a nice day :)
尝试将标题重命名为.hh,因为编译器仍将其视为目标C.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.