I have a parent with two children that I want to communicate with each other. For some reason it is not working. Here is what I have:
Parent
GameplayLayer *gameplaylayer = [GameplayLayer node]; // 1
[self addChild:gameplaylayer z:2 tag:1];
GameplayLayer2 *gameplaylayer2 = [GameplayLayer2 node]; // 1
[self addChild:gameplaylayer2 z:20 tag:2];
Child
.h
#import "GameplayLayer2.h"
@interface GameplayLayer : CCLayer {
GameplayLayer2* game;
}
.m
game = (GameplayLayer2*)[[self parent] getChildByTag:2];
But when I try to run a function in game like so [game runfun] it doesn’t run.
Check in debugger, that after this call
game instance is not
nil