This repository has been archived by the owner on Jan 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
SKNode+SSKTags.h
85 lines (77 loc) · 2.87 KB
/
SKNode+SSKTags.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#import <SpriteKit/SpriteKit.h>
/**
* Category that adds tag support to instances of SKNode
*
* @discussion Tags allow you to group your nodes using
* integer identifiers, and query for a node's child nodes,
* or nodes at a point, that has a certain tag.
*
* This category uses SKNode's userData dictionary to store
* the tag information, and thus requires other categories
* and node classes using this category to be good citizens
* regarding this dictionary. That is, not overwrite it
* when initialized, and instead just appending data to it.
*
* The tag will be stored under the key "SuperSpriteKit_Tag"
* in the node's userData dictionary.
*/
@interface SKNode (SSKTags)
/**
* The node's tag
*
* @discussion Defaults to 0
*/
@property (nonatomic, setter = ssk_setTag:) NSInteger ssk_tag;
/**
* Get the first direct child node of this node that has a certain tag
*
* @param tag The tag to look for
*
* @return The node that was found, or nil if no node was found
*/
- (SKNode *)ssk_childNodeWithTag:(NSInteger)tag;
/**
* Get the first child node of this node that has a certain tag, optionally
* performing a recusive search, looking at all nodes within this node's
* tree hierarchy, until a node with the specified tag is found.
*
* @param tag The tag to look for
* @param recursive Whether a recrusive search should be performed
*
* @discussion Since a full recurisve search can be quite expensive to
* perform (especially when complex and deep node trees are used), consider
* disabling recursive searching if only the direct children of this node
* should be searched.
*/
- (SKNode *)ssk_childNodeWithTag:(NSInteger)tag recursive:(BOOL)recursive;
/**
* Get all direct child nodes of this node that has a certain tag
*
* @param tag The tag to look for
*/
- (NSArray *)ssk_childNodesWithTag:(NSInteger)tag;
/**
* Get all child nodes of this node that has a certain tag, optionally
* performing a recusive search, looking at all nodes within this node's
* tree hierarchy.
*
* @param tag The tag to look for
* @param recursive Whether a recrusive search should be performed
*
* @discussion Since a full recurisve search can be quite expensive to
* perform (especially when complex and deep node trees are used), consider
* disabling recursive searching if only the direct children of this node
* should be searched, or use the -ssk_childNodeWithTag:recursive: API, to
* return the first found child who has the tag that is being searched for.
*/
- (NSArray *)ssk_childNodesWithTag:(NSInteger)tag recursive:(BOOL)recursive;
/**
* Get all child nodes at a point that has a certain tag
*
* @param tag The tag to look for
*
* @discussion This method will find nodes in the node's full tree hierarchy,
* using SpriteKit's built-in -nodesAtPoint:.
*/
- (NSArray *)ssk_nodesAtPoint:(CGPoint)point withTag:(NSInteger)tag;
@end