Skip to content

Commit

Permalink
just use containsPoint for hit test
Browse files Browse the repository at this point in the history
  • Loading branch information
saturnboy committed Feb 27, 2014
1 parent 5a07bea commit 7984d92
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions SKDemo/SKDemo/MyScene5.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

@interface MyScene5 ()

@property (nonatomic) SKTextureAtlas *atlas;
@property (nonatomic) SKSpriteNode *alien;
@property (nonatomic) SKSpriteNode *player;
@property (nonatomic) SKAction *anim;
@property (nonatomic) SKAction *fire;
@property (nonatomic) SKAction *miss;
@property (nonatomic) SKTextureAtlas *atlas;
@property (nonatomic,assign) NSInteger alienDir;

@end
Expand Down Expand Up @@ -91,7 +91,7 @@ -(void)update:(CFTimeInterval)currentTime {
NSLog(@"miss");
[self runAction:_miss];
[node removeFromParent];
} else if (_alien.alpha > 0.0f && CGRectContainsPoint(_alien.frame, node.position)) {
} else if (_alien.alpha > 0.0f && [_alien containsPoint:node.position]) {
//hit
NSLog(@"hit");
_alien.alpha = 0.0f;
Expand Down Expand Up @@ -124,4 +124,4 @@ -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[missile runAction:[SKAction fadeAlphaTo:1.0f duration:0.2f]];
}

@end
@end

0 comments on commit 7984d92

Please sign in to comment.