Problem trying to move a CCSprite circle in Cocos2d
Posted
by thyrgle
on Stack Overflow
See other posts from Stack Overflow
or by thyrgle
Published on 2010-05-16T23:28:38Z
Indexed on
2010/05/16
23:30 UTC
Read the original article
Hit count: 376
cocos2d-iphone
|collision-detection
Hi,
So I am trying to move a CCSprite (which has the picture of a circle and is 32 by 32 pixels) with ccTouchesBegan. I have tried the following:
-(void) ccTouchesBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
CGPoint location = [touch locationInView:touch.view];
if ((location.x <= L1Circle1.position.x + 32 && location.x >= L1Circle2.position.x - 32) && (location.y <= L1Circle1.position.y + 32 || location.y >= L1Circle2.position.y - 32))
{
L1Circle1.position = ccp(location.x, location.y);
}
}
But, when I touch the screen in the simulator nothing happens... What am I doing wrong?
© Stack Overflow or respective owner