I am trying to make a single game that when you touch the star image it will load an star sprite from Star class. My star image has its own class (StarImage) which calls my Level class StarLauncher method when thouched using level class method. Problem is that when I touch the star it calls the level class StarLauncher methode but it does not add star sprite at all. It can print clog messages though..
Here is the Level class
#import "Level.h"
#import "CCPhysics+ObjectiveChipmunk.h"
#import "Star.h"
#import "StarImage.h"
@implementation Level{
CCPhysicsNode *_physicsNode;
}
-(void)StarLauncher{
CCLOG(@"haaaaaaaaaaa");
Star *_Star2=(Star*)[CCBReader load:@"Star"];
[_Star2 setScale:0.5];
_Star2.position=CGPointMake(160,478);
[_physicsNode addChild:_Star2];
}
-(void) update:(CCTime)delta{
[self StarLauncher]; // when called here it will do add operation
}
@end
and here is my StarImage class
#import "StarImage.h"
#import "Level.h"
@implementation StarImage{
}
- (void)didLoadFromCCB{
self.userInteractionEnabled = TRUE;
}
-(void)touchBegan:(CCTouch *)touch withEvent:(CCTouchEvent *)event{
}
-(void)touchEnded:(CCTouch *)touch withEvent:(CCTouchEvent *)event{
Level *_LevelOlio=[[Level alloc]init];
[_LevelOlio StarLauncher]; // it calls but the methode will only print clog
}
The problem is that StarLauncher will not do the adding operation when called from StarImage but when I call it in Level class it does work.. what I am missing here? why it wouldnt do the same piece of code when I call it from other class? but why it prints clog? When i debugged it it shows that when called from StarImage it runs the code but nothing appear in simulator