ios - Objective C - SKNode subclass to 'swallow' touches? -
I am trying to subclass a sqn
so that when you its frame (touch) , it has been notified by the Chittegabian ::
method.
However, it seems that it will be notified only when someone SKSpriteNode
has touched the child. I tried to override the included in :
method but not with success.
Here is my code:
@interface gameNode: SKNode {SKSpriteNode * MainChar;} @ Property (weak, non-nominal) id & lt; gameNodeDelegate & gt; representative; @end @implementation GameNode // When touched, touches: Method: Not being called method - (id) init {if ( Self = [super init]) {self.userInteractionEnabled = YES; maincars = [SKSPractnode node]; // When touched, touches: method called MainChar.color = [SKColor redColor]; MainChar.size = CGSizeMake (25 , 25); [Main move: [SKAK scale: 0 duration: 0]]; Main buyer = CP point make (100, 100); [Self linking child: chief minister]; SKSpriteNode * n = [SKSpriteNode node]; // When touched, then touches: method is called. N.size = mainChar.size; N.position = CG point make (-100, -100); N.color = [SKColor greenColor]; [Self combine: n]; [Main car driving: [Scouting Custom Animation with Properties: CuPropertiesFor Skybouns (CUdirects type 1, 1)]]; } Healthy return; } - (zero) touches: (touchs the NSSE *) event: (UIEvent *) event {NSLOG (@ "This is a touch!"); } (Void) Touch cancel: (NSSET *) touches the event: (UIEVENT *) Event {} - (zero) touched end: (NSSET *) touches with the event: (UIEVENT *) Event {} - (Zero) touch Translation: (UIEvent *) Event {} @end
What happens to me is that I get only one touch event when the main cell and n < Code> SKSpriteNodes touched the nodes and not in the rest of the screen.
The only way I could think of it to work is to add a transparent SKSpriteNode
to the background, but there should be a better way!
How can I make it so that despite the child being a child, SKNode
'touching it swallowing' should be touched or not? that is, I want to notice the frame in the SKNodes
via touch
method.
Update: I think this is a problem with the frame of SKNode
after I add children. .
NSLog (@ "frame width:% f, frame height:% f", self.frame.size.width, self.frame.size height);
The frame is returned as the height and width. However, when I do [self calculateAccumulatedFrame]
, then it gives the correct size why is it?
Update: This question is a complete mess I just add a transparent SKSpriteNode
or the solution to use SKScene
I want to be with Sorry for everything, I appreciate your help.
a The functionality you are seeking is best provided by does not have an internal border, it does not have any drawing , And you can effectively think that it is not being shown on screen. It will not detect touch.
SKScene
. SKScene
.
Comments
Post a Comment