我有這樣的:怪異的行爲,同時繼承CCSprite
//Node.h
@interface Node: CCSprite{
BOOL wasTouched;
}
-(BOOL)getTouched;
// some other methods
//Node.m
-(BOOL)getTouched{
return wasTouched;
}
-(id)init{
wasTouched=NO;
}
//wasTouched changes in the other methods..when they are called (no problem here)
//Game.m
//i make an array of nodes and do some stuff
-(void)someMethod{
for (Node *node in arrayOfNodes){
if ([node getTouched]) { //here it crashes
//code
}}}
它與消息崩潰-[CCSprite getTouched]: unrecognized selector sent to instance 0x236dd0
的問題是:爲什麼?
你怎麼收到'arrayOfNodes',你可以確認在真正只包含'Node'對象和沒有'CCSprite'? – Tharabas
我在Game的init方法中創建了一個隨機的節點數組,我檢查過了,ot她的自定義方法工作..只有這不。我試圖重寫我的代碼來解決這個問題 – skytz