我正在处理一个应用源代码,该代码由于某种原因禁用了In App Purchase代码(已注释掉)。该游戏是在Cocos 2dx中构建的。
现在,我对C ++一无所知,但我研究过试图找到答案并且我被卡住了。
我得到了编译错误:
Undefined symbols for architecture arm64:
"BLACKJACK::BlackJackSetting::submitScore(int)", referenced from:
MainMenuLayer::onLeaderBoard(cocos2d::CCObject*) in MainMenuLayer.o
"BLACKJACK::BlackJackSetting::showLeaderboard()", referenced from:
MainMenuLayer::onLeaderBoard(cocos2d::CCObject*) in MainMenuLayer.o
"BLACKJACK::BlackJackSetting::isAvailable()", referenced from:
MainMenuLayer::onLeaderBoard(cocos2d::CCObject*) in MainMenuLayer.o
"_WebPDecode", referenced from:
cocos2d::CCImage::_initWithWebpData(void*, int) in CCImageCommonWebp.o
"BLACKJACK::BlackJackSetting::isCoins1000()", referenced from:
ShopLayer::onClickPopBuy() in ShopLayer.o
"BLACKJACK::BlackJackSetting::dispChartboostBanner()", referenced from:
MainMenuLayer::init() in MainMenuLayer.o
"BLACKJACK::BlackJackSetting::shared()", referenced from:
ShopLayer::onClickPopBuy() in ShopLayer.o
MainMenuLayer::init() in MainMenuLayer.o
MainMenuLayer::onLeaderBoard(cocos2d::CCObject*) in MainMenuLayer.o
以下是整个代码块:
void ShopLayer::onClickPopBuy() {
if (g_nProgressBuy != -1) {
itemPopBuy->setEnabled(false);
AndroidSocial::shared()->buyFeatureB(m_curPopIdx);
g_nProgressBuy = -1;
this->schedule(schedule_selector(ShopLayer::onProcessBuy), 0.5f);
}
if ( spPop1->isVisible() ) {
// Compiler Error: use of undeclared identifier 'BLACKJACK'
BLACKJACK::BlackJackSetting* bj = BLACKJACK::BlackJackSetting::shared();
if ( bj->isPaidVersion() ) {
bj->processIAP("com.prismstudios.BlackjackPaid.coin1000");
}
else
{
bj->processIAP("com.prismstudios.Blackjackfree.coin1000");
}
GameSetting* gameSetting = GameSetting::shared();
gameSetting->getCoins();
if ( bj->isCoins1000() ) {
g_nYourCoin += 1000;
}
gameSetting->saveCoins();
}
}
更新 - BlackJackSetting.m文件:
static void static_setEnable(bool enable){
NSLog(@"enable GC %d", enable);
BLACKJACK::BlackJackSetting *gc = BLACKJACK::BlackJackSetting::shared();
gc->isEnabled = enable;
}
namespace BLACKJACK
{
static BlackJackSetting* bjSetting;
BlackJackSetting::BlackJackSetting()
{
}
BlackJackSetting::~BlackJackSetting()
{
}
BlackJackSetting* BlackJackSetting::shared()
{
if ( !bjSetting )
{
bjSetting = new BlackJackSetting();
}
return bjSetting;
}
void BlackJackSetting::alertDialog()
{
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
[app alertDialog];
}
void BlackJackSetting::dispChartboostBanner()
{
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
[app dispChartboostBanner];
}
void BlackJackSetting::dispChartboostMoreGames()
{
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
[app dispChartboostMoreGame];
}
void BlackJackSetting::dispAppLovin()
{
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
[app dispAppLovin];
}
bool BlackJackSetting::isPaidVersion()
{
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
return [app isPaidVersion];
}
void BlackJackSetting::showPlayHavenBanner(int nType)
{
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
[app showPlayHavenBanner:nType];
}
void BlackJackSetting::onRestore()
{
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
[app onRestore];
}
void BlackJackSetting::processIAP(const char* sz)
{
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
[app processIAP:[NSString stringWithUTF8String:sz]];
}
bool BlackJackSetting::isCoins1000()
{
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
return [app isCoins1000];
}
bool BlackJackSetting::isCoins2500()
{
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
return [app isCoins2500];
}
bool BlackJackSetting::isCoins6000()
{
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
return [app isCoins6000];
}
bool BlackJackSetting::isCoins14000()
{
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
return [app isCoins14000];
}
bool BlackJackSetting::isCoins30000()
{
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
return [app isCoins30000];
}
bool BlackJackSetting::isAvailable(){
// Check for presence of GKLocalPlayer API.
Class gcClass = (NSClassFromString(@"GKLocalPlayer"));
// The device must be running running iOS 4.1 or later.
NSString *reqSysVer = @"4.1";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
BOOL osVersionSupported = ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending);
return (gcClass && osVersionSupported);
return YES;
}
void BlackJackSetting::playerLogin(){
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) {
if (error == nil)
{
static_setEnable( true );
NSLog(@" Authenticate local player complete");
}
else
{
static_setEnable( false );
NSLog(@"Authenticate local player Error: %@", [error description]);
}
}];
}
void BlackJackSetting::showLeaderboard(){
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
[app showLeaderboard];
}
void BlackJackSetting::submitScore(int score){
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
NSString *category =@"gr.com.goldcion.blackjack.leaderboard";
if ( [app isPaidVersion] )
{
category =@"com.goldcion.blackjack.leaderboard";
}
[NSBundle mainBundle];
NSLog(@"Submitting score for identifier: %@", category);
GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:category] autorelease];
scoreReporter.value = score;
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil)
{
NSLog(@"Submitting score error: %@", [error description]);
}
else {
NSLog(@"Submitting score success");
}
}];
}
}
答案 0 :(得分:0)
看起来这个代码是从其他项目导入的。 BLACKJACK是一个名称空间,用于定义引用的范围。你需要一个BlackJackSetting类(即它的所有代码)。您可能根本不需要命名空间(BLACKJACK)。