Nextpeer删除欢迎横幅:未触发委托方法

时间:2013-06-08 06:20:51

标签: cocos2d-iphone nextpeer

我试图在游戏开始时删除nextpeer欢迎通知。

这是我在.h

中的代码
@interface AppDelegate : NSObject <UIApplicationDelegate,NextpeerDelegate,NPTournamentDelegate,NPNotificationDelegate,..>

//在AppDelegate.m中

- (void)initializeNextpeer
{
    NSDictionary* settings = [NSDictionary dictionaryWithObjectsAndKeys:

                              // This game has no retina support - therefore we have to let the platform know
                              [NSNumber numberWithBool:TRUE], NextpeerSettingGameSupportsRetina,
                              // Support orientation change for the dashboard notifications
                              [NSNumber numberWithBool:FALSE], NextpeerSettingSupportsDashboardRotation,
                              // Support orientation change for the in game notifications
                              [NSNumber numberWithBool:TRUE], NextpeerSettingObserveNotificationOrientationChange,
                              //  Place the in game notifications on the bottom screen (so the current score will be visible)
                              [NSNumber numberWithInt:NPNotificationPosition_BOTTOM], NextpeerSettingNotificationPosition,
                              nil];



    [Nextpeer initializeWithProductKey:@"HERE ADDED GAME KEY" andSettings:settings andDelegates:
     [NPDelegatesContainer containerWithNextpeerDelegate:self notificationDelegate:[NPCocosNotifications sharedManager] tournamentDelegate:self]];


}
- (BOOL)nextpeerShouldShowWelcomeBanner {
    return NO; // Do not Show banner
}

Nextpeer工作得很好。仅触发此功能。怎么了?

2 个答案:

答案 0 :(得分:1)

nextpeerShouldShowWelcomeBannerNPNotificationDelegate上的方法,而不是NextpeerDelegate上的方法。在您的代码示例中,通知委托为[NPCocosNotifications sharedManager]。因此,您应该将方法移动到该对象,或者设置不同的通知委托。

答案 1 :(得分:1)

编辑:这不再适用 - 似乎当前版本的Nextpeer(1.7.4)不支持此功能。

您需要将该方法添加到实施NPNotificationDelegate而不是NextPeerDelegate的任何一个类。

但问题是,默认NPNotificationDelegateNPCocosNotifications - 这是Nextpeer库中的一个类。因此,当您更新库时,您还需要记住再次对新版NPCocosNotifications进行相同的编辑。

但使用类别有一种更简洁的方法,这意味着您在更新时无需再次进行编辑。

1)

创建此文件:NSObject+NPCocosNotification_NotShowWelcomeBanner.h

#import <Foundation/Foundation.h>
#import "NPCocosNotifications.h"

@interface NPCocosNotifications (NPCocosNotification_NotShowWelcomeBanner)

@end

创建此文件:NSObject+NPCocosNotification_NotShowWelcomeBanner.m

#import "NSObject+NPCocosNotification_NotShowWelcomeBanner.h"

@implementation NPCocosNotifications (NPCocosNotification_NotShowWelcomeBanner)

- (BOOL)nextpeerShouldShowWelcomeBanner {
    return NO; // Do NOT show banner as the game starts up
}

@end

将这些文件拖到项目中,确保选中“复制到目标组的文件夹(如果需要)”和“添加到目标(项目的构建目标名称)”。

2) 将此行添加到您的应用代理和引用NPCocosNotification

的任何其他文件
// This adds a method to prevent the welcome banner showing
#import "NSObject+NPCocosNotification_NotShowWelcomeBanner.h"

关闭横幅的新方法将添加到NPCocosNotifications:)

相关问题