iPhone用のcocos2dでアクションシーケンスのコールバック関数を作成しようとしていますが、悪いアクセスエラーが発生し続けます。
ここでコールバックを作成します
id myCallFunc = [CCCallFuncND actionWithTarget:self.delegate selector:@selector(playerAttack:data:) data:(__bridge void *)([[PlayerAttackPacket alloc] initWithPlayer:@"" attackChoice: [NSNumber numberWithInt: item.tag]]) ]; // to call our method
そして、これがコールバックされた関数です。データをキャストするときに、コンパイラはアクセスが悪いと言います。
-(void) playerAttack:(id)sender data:(void *)data
{
PlayerAttackPacket* packet = (__bridge PlayerAttackPacket*)data;
BattleModel *model = [BattleModel sharedInstance];
int choice = packet.attackChoice.intValue;
NSString * players = packet.player;
}
プレーヤー パケット:
@interface PlayerAttackPacket : NSObject {
NSString * player;
NSNumber * attackChoice;
}
@property (nonatomic, retain) NSString * player;
@property (nonatomic, retain) NSNumber * attackChoice;
-(id) initWithPlayer: (NSString*)_player attackChoice: (NSNumber*)choice;
@end
@implementation PlayerAttackPacket
@synthesize player,attackChoice;
-(id) initWithPlayer: (NSString*)_player attackChoice: (NSNumber*)choice
{
if((self=[super init]))
{
self.player = _player;
self.attackChoice = choice;
}
return self;
}
@end
誰が私が間違っているのか教えてもらえますか? =(. ARC と何か関係があるように感じますが、よくわかりません。