I've been trying to get my sprit to move but it wont budge! Im using cocos2d v2.1 beta 2 and ios6 this is the code i've been using to move my sprite, whats wrong with it?
#import "CCTouchDispatcher.h"
CCSprite *faceeater;
-(id) init
{
if( (self=[super init]) ) {
}
CCSprite* faceeater = [CCSprite spriteWithFile:@"fe.png"];
faceeater.position = ccp( 200, 300 );
[self addChild:faceeater];
[self schedule:@selector(nextFrame:)];
[[CCDirector sharedDirector] touchDispatcher];
self.isTouchEnabled = YES;
return self;
}
- (void) nextFrame:(ccTime)dt {
faceeater.position = ccp( faceeater.position.x + 100*dt, faceeater.position.y );
if (faceeater.position.x > 480+32) {
faceeater.position = ccp( -32, faceeater.position.y );
}
}
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
return YES;
}
- (void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event {
CGPoint location = [self convertTouchToNodeSpace: touch];
[faceeater stopAllActions];
[faceeater runAction: [CCMoveTo actionWithDuration:1 position:location]];
}
I can see the sprite but no matter what i don it doesn't move. Thanks.