繁体   English   中英

Objective C和c ++导入问题。 很简单,但我不明白

[英]Objective C and c++ import problem. Simple but I don't get it

我正在使用cocos2d和box2d。(iPhone SDK)如果我要导入box2d,我将它添加到文件#import“Box2D.h”的顶部,然后我将我的类重命名为“ .mm ”。 现在我只有一个没有 “.m”文件的类只是一个“.h”文件。

它看起来像那样,如果我导入box2d它给了我很多错误,因为box2d是c ++,通常我需要将它改为“.mm”,但我不能。

#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;

为什么我要这样做? 查看我的代码中的“ * * important”。 我想用b2Vec2。

非常感谢您的阅读。 祝你今天愉快 :)

尝试将标题重命名为.hh,因为编译器仍将其视为目标C.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM