当我从“Cocos2d-x 初学者指南”一书中做一个教程(空气曲棍球)时,我在 Cocos2d-x(2.1.5)中收到这些消息。
我已经检查了 Xcode 中的所有“#include”、BuildPhases 等,并在“编译源”(大约 250 个文件)中执行了“验证设置”并筛选了互联网,并希望有人对此有看法。我还没有在 .cpp 文件中提到它们。
顺便说一句,书中的 Cocos2d-x 版本与我使用的不一样,我检查了书籍网站并从作者那里找到了这个:作者对教程发布的评论
这是我第一次尝试非 Objective-C 和 Cocos2d-x。
GameLayer.h:
#ifndef __GAMELAYER_H__
#define __GAMELAYER_H__
#define GOAL_WIDTH 400
#include "cocos2d.h"
#include "GameSprite.h"
using namespace cocos2d;
class GameLayer : public cocos2d::CCLayer {
GameSprite *_player1;
GameSprite *_player2;
GameSprite *_ball;
CCArray *_players;
CCLabelTTF *_player1ScoreLabel;
CCLabelTTF *_player2ScoreLabel;
CCSize _screenSize;
int _player1Score;
int _player2Score;
void playerScore (int player);
public:
~GameLayer();
virtual bool init();
static CCScene *scene();
CREATE_FUNC(GameLayer);
virtual void ccTouchesBegan(CCSet* pTouches, CCEvent* event);
virtual void ccTouchesMoved(CCSet* pTouches, CCEvent* event);
virtual void ccTouchesEnded(CCSet* pTouches, CCEvent* event);
void update (float dt);
};
#endif // __GAMELAYER_H__
消息:
clang: warning: argument unused during compilation: '-websockets'
Undefined symbols for architecture i386:
"GameLayer::ccTouchesBegan(cocos2d::CCSet*, cocos2d::CCEvent*)", referenced from:
vtable for GameLayer in GameLayer.o
"GameLayer::ccTouchesEnded(cocos2d::CCSet*, cocos2d::CCEvent*)", referenced from:
vtable for GameLayer in GameLayer.o
"GameLayer::ccTouchesMoved(cocos2d::CCSet*, cocos2d::CCEvent*)", referenced from:
vtable for GameLayer in GameLayer.o
"GameLayer::update(float)", referenced from:
vtable for GameLayer in GameLayer.o
"non-virtual thunk to GameLayer::ccTouchesBegan(cocos2d::CCSet*, cocos2d::CCEvent*)", referenced from:
vtable for GameLayer in GameLayer.o
"non-virtual thunk to GameLayer::ccTouchesEnded(cocos2d::CCSet*, cocos2d::CCEvent*)", referenced from:
vtable for GameLayer in GameLayer.o
"non-virtual thunk to GameLayer::ccTouchesMoved(cocos2d::CCSet*, cocos2d::CCEvent*)", referenced from:
vtable for GameLayer in GameLayer.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)