のメソッドを呼び出すことはできません私が持っているCocos2D:親クラスで私のシーンで
//.h
#import "cocos2d.h"
#import "FixedBackground.h"
@class FixedBackground;
#import "JoinedMapsLayer.h"
@class JoinedMapsLayer;
@interface JoinedMapsScene : CCScene {
FixedBackground *fixedBackground;
JoinedMapsLayer *joinedMapsLayer;
}
@property(nonatomic, retain) FixedBackground *fixedBackground;
@property(nonatomic, retain) CCNode *joinedMapsLayer;
+(id) scene;
- (void) moveBG:(float)x andY:(float)y;
- (int) getInt;
@end
//.m
私が呼び出そうとjoinedMapsLayerのinitメソッドで#import "JoinedMapsScene.h"
@implementation JoinedMapsScene
@synthesize fixedBackground;
@synthesize joinedMapsLayer;
+(id) scene {
// 'scene' is an autorelease object.
CCScene *scene = [CCScene node];
// 'layers' are an autorelease object.
JoinedMapsScene *layer1 = [JoinedMapsScene node];
// add layers as a childs to scene
[scene addChild: layer1];
return scene;
}
-(id) init {
if((self=[super init])) {
fixedBackground = [FixedBackground node];
joinedMapsLayer = [JoinedMapsLayer node];
// add layers as a children of the scene
[self addChild:fixedBackground];
[self addChild:joinedMapsLayer];
}
return self;
}
- (int)getInt {
return 100;
}
- (void) dealloc{
[super dealloc];
}
@end
getIntを返し、値100を返しますが、0を返します。
NSLog(@ "%d"、[(JoinedMapsScene *)self.parent getInt]);
これはなぜ起こっているのか?私のシーンが正しく書かれていないのですか?
.hファイルも記述できますか?私は問題が構造化していると思います... –
.h – VagueExplanation