我遇到了一个奇怪的问题......我有一个带有sprite和booleans属性的自定义类
在我的主GameLayer
中,我有CCLayerColor *my1layer
,在我的.m部分,我有这段代码:
my1layer = [CCLayerColor layerWithColor:ccc4(144,238,144, 255)];
[self addChild: my1layer z:5 tag:100];
[my1layer setContentSize:CGSizeMake(200, 1280)];`
//default start position
my1layer =ccp(s.width/2-420, s.height-s.height+180.);
MylmageItem *postImage1 = [[MylmageItem alloc] initWithLayer:self];
[postImage1 release];
postImage1.postImageNum=CCRANDOM_0_1()*12 +1;
postImage1.postImage = [CCSprite spriteWithSpriteFrameName:(NSString*)[self assignPostImage:postImage1.postImageNum ]];
postImage1.postImage.position =ccp(my1layer.contentSize.width/2, my1layer.contentSize.height-my1layer.contentSize.height+80);
[my1layer addChild:myImage1.slotImage z:6 tag:101];’
上面的代码确实可以工作并在图层上显示图像,但是当我尝试访问属性postImage1.postImageNum时,它总是显示0 ...
我这样做:CCLayer *myLayer1 = (CCLayer*)[self getChildByTag:100];
稍后检索我的对象......
MyImageItem *tmpImage1 = (MymageItem*)[myLayer1 getChildByTag:101];
从这里开始CCLOG(@"postImage1.postImageNum %d",tmpImage1.postImageNum);
如何从my1layer
获取数据?