i have this void function that makes a sprite move if a touch is detected:
-(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:[touch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
car.position = ccp(0,10);
}
the game runes fine, but when i touch the screen it freezes when its meant to move the car sprite, thanks for your help!!
1 way is
[car setposition:location];
it will directly place your car at your touch. Other way is
[car runAction:[CCMoveTo actionWithDuration:1 position:location]];
Check for spelling. I dnt have IDE to check every spelling. :) Hope this helps
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.