【求助】update方法不能正常调用
我在写一个小demo,有一个类是继承自CCSprite的,在里面添加了计时器之后 不会自动调用update方法,在主场景里添加的计时器可以正常工作,下面附上源码,纠结大半天了,求指点~先谢过了(PS:留个邮箱我可以传源文件)785685927@qq.com
#import "Dodge.h"
@implementation Dodge
+(id) addDodgeWithRandomPos:(CGPoint)position andSpriteBatchNode:(CCSpriteBatchNode *)spriteBatchNode {
return [[[self alloc] initWithRandomPos:position andSpriteBatchNode:spriteBatchNode] autorelease];
}
-(id) initWithRandomPos:(CGPoint)position andSpriteBatchNode:(CCSpriteBatchNode *)spriteBatchNode {
if(self == [CCSprite spriteWithSpriteFrameName:@"dodge.png"]) {
speedX = 10;
speedY = 15;
//self = [CCSprite spriteWithSpriteFrameName:@"dodge.png"];
[self setPosition:position];
[spriteBatchNode addChild:self];
[self scheduleUpdate];
}
return self;
}
-(void) update:(ccTime)dt {
CCLOG(@"-----------------");
}
-(void) dealloc {
[super dealloc];
}
@end