3
我不明白爲什麼如果我繼承SKSpriteNode,實現UIResponder協議,與觸摸相關的方法永遠不會被調用。SKSpriteNode子類和觸及事件
例如,這是一個非常簡單的類,我現在把它用作測試:
//INTERFACE ----------------
#import <SpriteKit/SpriteKit.h>
@interface TestClass : SKSpriteNode
@end
//IMPLEMENTATION -----------
#import "TestClass.h"
@implementation TestClass
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"oook");
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{}
@end
如果我重視這個類的一個實例到現場,接觸對象......什麼都不會發生。
我忘了什麼嗎?
但是,如果它覆蓋的sprite沒有啓用互動功能,覆蓋雪碧會吞噬觸摸...... – DogCoffee
@Smick,你的意思是如果他們有userinteractionEnabled = YES,可以點擊「through」覆蓋子畫面? – bobmoff
我只是試過這個,如果覆蓋精靈有userInteractionEnabled或者沒有,它似乎並不重要,它會阻止下面的精靈觸摸。我很想找到解決此問題的方法,因爲我希望透明雲在forground中移動。 – bobmoff