В приложении «Покупка для Cocos2Dx» используйте необъявленный идентификатор. в игре iOS

Я работаю над исходным кодом приложения, в котором по какой-то причине отключен код покупки в приложении (закомментировано). Игра была построена на Cocos 2dx.

Теперь я ничего не знаю о C ++, но я попытался найти ответ на этот вопрос, и я застрял.

Я получаю ошибки Complier:

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");
}

}];
}
}

3

Решение

Похоже, этот код импортирован из какого-то другого проекта. BLACKJACK — это пространство имен, которое определяет область действия ссылки. Вам нужен класс для BlackJackSetting (т.е. весь код для него). Вероятно, вам вообще не нужно пространство имен (BLACKJACK).

0

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]