0
我主要功能那里我画背景:绘制图像在cocos2d
-(id) init
{
if((self=[super init])) {
CGSize size = [[CCDirector sharedDirector] winSize];
CCSprite * background = [CCSprite spriteWithFile:@"backg.png"];
background.anchorPoint = ccp(1, 1);
background.position = ccp(size.width, size.height);
[self addChild:background z:-1];
self.isTouchEnabled = YES;
}
return self;
}
和功能在那里我得到触摸,然后对程序逻辑。但我不知道我怎么能从她身上吸引。
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
int a[3][3],fail,hod,i,k,win,x,y;
for(i=1; i<=3; i++)
{
for(k=1; k<=3; k++)
{
a[i][k]=0;
}
}
win=0;
hod=1;
while(win==0)
{
if(hod%2==1)
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:[touch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
x=location.x;
y=location.y;
NSLog(@"%d %d",x,y);
//here i should draw
hod++;
}
}
}
如何,我可以从第二个功能上攻背景,发生在第一功能绘制一个形象呢?