【发布时间】:2025-11-21 20:05:02
【问题描述】:
我正在将基于 Cocos2dx 的游戏从 iOS 移植到 Windows Phone 8。这里的问题是在我更改修复 API 差异的所有错误后,我得到了一堆语法错误,未声明的变量(虽然这些变量是声明)。这是我的示例代码: .h 文件:
#ifndef __Bomb__
#define __Bomb__
#include "MoveableObject.h"
typedef enum BombType {
BombTypeElectrical,
BombTypeIce,
BombTypeChemical,
BombTypeSmall,
BombTypeBig
} BombType;
class Bomb : public MoveableObject {
public:
Bomb() {};
Bomb(const char* szName);
virtual ~Bomb() {};
void setType(int nType) { m_nType = nType; };
int getType() { return m_nType; };
bool isExploding() { return m_bExploding; };
int bombTypeForName(const char* szName);
void expode();
void activate();
void finishExploding();
protected:
bool m_bExploding;
int m_nType;
};
#endif
并且错误标记在这里:
Bomb::Bomb(const char* szName) : MoveableObject(szName), m_bExploding(false) {
m_nType = this->bombTypeForName(szName);
}
错误 28 错误 C3861:“m_bExploding”:找不到标识符 以前有人遇到过这个问题吗?我怎么能像这样解决这些问题(总共有 420 个错误)?任何帮助表示赞赏。 谢谢。
【问题讨论】:
-
没有找到 Bomb 类的标题吗?
-
不,我已经在Bomb.cpp中包含了Bomb.h,编译器没有显示错误(下划线变量),但是当我构建项目时,它显示在错误列表中
-
发布更多错误。
-
可能不是你的错误的原因,但你有未定义的行为。任何带有两个连续下划线的标识符都是为您的编译器保留的,不得在用户代码中使用。 Dtto 表示以下划线开头后跟大写字母的标识符。
-
感谢@Angew,但我还有更多问题,例如语法错误或未定义的类或命名空间。它们是:CCAnimate* wagTailAnimate = CCAnimate::actionWithAnimation(wagTailAnimation); CCDelayTime* delayAction = CCDelayTime::actionWithDuration(2.5); CCCallFunc* callFuncAction = CCCallFunc::actionWithTarget(this, callfunc_selector(Player::dogWagTail)); CCFiniteTimeAction* wagTailAction = CCSequence::actions(wagTailAnimate, delayAction, callFuncAction, NULL);这是错误:错误 431 错误 C2653: 'CCSequence' : is not a class or namespace name
标签: c++ visual-studio-2012 windows-phone-8 cocos2d-x