@Tim: I've looked around, but none of them seem to do the trick. Granted, that I am new to this.
@David994A: That's what I would of thought. If I would just simply declare it in the header file, it should of done the trick. But apparently not.
@slipster216:Hmm, that doesn't seem to work. It seems easy enough, but it just doesn't work...
To help you out, and even myself, here's the code:
In 1.m (yes, I did alter the file names...) under "-(id) init"
CCSprite *one = [CCSprite spriteWithFile:@"01.png"];
one.position = ccp( size.width /2 , size.height /2 ); //size is declared in a previous statement
[self addChild: one];
Then in 2.m I'm detecting the touches in a certain region, and then I would like to do things to the sprite:
- (BOOL) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *) event {
UITouch* touch = [touches anyObject];
CGPoint location = [touch locationInView: [touch view]];
CGRect touchregion = CGRectMake(180, 0, 300, 320);
if(CGRectContainsPoint(touchregion, location)) {
//touchregion touched
//this is why I would need the global variable. It says it's not declared, and yes, I did import 1.h.
id myAction = [CCRotateBy actionWithDuration:72 angle:360];
id RepeatAction = [CCRepeatForever actionWithAction: myAction];
[one runAction: RepeatAction];
[self addChild: one];
}
return kEventHandled;
}
I hope that might help. I'm sorry I'm such a noob at this, but I know this awesome community will be able to help a dev out.