0
我有一個代碼,根據你觸摸屏幕的位置設置了一個弓的角度。 對ccTouchesMoved事件執行簡單的「bow.rotation = X」命令。 問題是,雖然運行0.7.1 cocos2d上的代碼0.9或0.8.2 它運行的方式更好,在0.9和0.8.2它似乎skippes一些touchesmove事件...它可能是什麼是? 繼承人的代碼...:iphone-cocos2d:0.9&0.8.2慢於0.7.1?
-(BOOL)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView: [touch view]];
location = [[CCDirector sharedDirector] convertToGL: location];
if(player.state == StateNotPrepared) {
if(CGRectContainsPoint(spriteToRect(fireButton), location)) {
[player prepareShot];
[powerMeter resetBar];
[powerMeter startLoadingBar];
} else {
float newAngle = [player angleByTouchPoint: location];
[self setAngles: newAngle];
}
}
return kEventHandled;
}
-(BOOL)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView: [touch view]];
location = [[CCDirector sharedDirector] convertToGL: location];
if(player.state == StateNotPrepared || player.state == StatePrepared) {
if(!CGRectContainsPoint(spriteToRect(fireButton), location)) {
float newAngle = [player angleByTouchPoint: location];
[self setAngles: newAngle];
}
}
return kEventHandled;
}
在0.9我找不到任何方法setDirectorType: [[CCDirector sharedDirector] setDirectorType]; 沒有這樣的方法 – 2010-01-05 20:11:02
它在那裏。你甚至可以看到它用在像TileMapTest.m中: \t [CCDirector setDirectorType:CCDirectorTypeDisplayLink]; – 2010-01-06 05:14:34
你說得對,它存在。您必須在類itlsef上調用setDirector類型,而不是在sharedDirector實例上調用setDirector類型,並且在對sharedDirector執行其他任何操作之前必須先調用setDirector類型。 謝謝。 – 2010-01-06 10:33:03