{"id":3112,"date":"2013-09-25T12:08:26","date_gmt":"2013-09-25T03:08:26","guid":{"rendered":"http:\/\/peta.okechan.net\/blog\/?p=3112"},"modified":"2015-04-22T17:53:09","modified_gmt":"2015-04-22T08:53:09","slug":"spritekit%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b-%e3%81%9d%e3%81%ae3","status":"publish","type":"post","link":"https:\/\/peta.okechan.net\/blog\/archives\/3112","title":{"rendered":"SpriteKit\u3092\u4f7f\u3063\u3066\u307f\u308b \u305d\u306e3"},"content":{"rendered":"<p><a href=\"https:\/\/peta.okechan.net\/blog\/archives\/3084\" title=\"SpriteKit\u3092\u4f7f\u3063\u3066\u307f\u308b \u305d\u306e2\">\u524d\u56de<\/a>\u3001SpriteKit\u306e\u7269\u7406\u30a8\u30f3\u30b8\u30f3\u3092\u5229\u7528\u3057\u305f\u7c21\u5358\u306a\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3057\u305f\u3002<br \/>\n\u4eca\u56de\u306f\u305d\u306e\u30a2\u30d7\u30ea\u306b\u3001SpriteKit\u306e\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u30b7\u30b9\u30c6\u30e0\u3092\u5229\u7528\u3057\u305f\u3061\u3087\u3063\u3068\u3057\u305f\u30a8\u30d5\u30a7\u30af\u30c8\u3092\u8ffd\u52a0\u3057\u3066\u307f\u308b\u3002<\/p>\n<h3>\u76ee\u6a19<\/h3>\n<p>\u30dc\u30fc\u30eb\u306b\u3042\u308b\u4e00\u5b9a\u4ee5\u4e0a\u306e\u885d\u6483\u304c\u52a0\u308f\u3063\u305f\u3089\u706b\u82b1\u3092\u6563\u3089\u3059\u3002<br \/>\n\u4eca\u56de\u306e\u5834\u5408\u3060\u3068\u3001\u30dc\u30fc\u30eb\u304c\u753b\u9762\u306e\u67a0\u3084\u30dc\u30fc\u30eb\u540c\u58eb\u3067\u3076\u3064\u304b\u3063\u305f\u3068\u304d\u306b\u706b\u82b1\u304c\u767a\u751f\u3059\u308b\u3088\u3046\u306b\u306a\u308b\u3002<br \/>\n<a href=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.51.02.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.51.02-180x300.png\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-09-25 7.51.02\" width=\"180\" height=\"300\" class=\"alignnone size-medium wp-image-3114\" srcset=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.51.02-180x300.png 180w, https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.51.02.png 594w\" sizes=\"auto, (max-width: 180px) 100vw, 180px\" \/><\/a><\/p>\n<h3>\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u30c7\u30b6\u30a4\u30f3<\/h3>\n<p>\u3069\u3046\u3044\u3046\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306b\u3059\u308b\u304b\u306f\u30b3\u30fc\u30c9\u3067\u3082\u6307\u5b9a\u3067\u304d\u308b\u304c\u3001Xcode 5\u304b\u3089SpriteKit\u306e\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u3092GUI\u3067\u30c7\u30b6\u30a4\u30f3\u3067\u304d\u308b\u6a5f\u80fd\u304c\u8ffd\u52a0\u3055\u308c\u305f\u306e\u3067\u3001\u305d\u308c\u3092\u4f7f\u3063\u3066\u307f\u308b\u3002<\/p>\n<p>\u307e\u305a\u3001\u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u306e\u8ffd\u52a0\u3067 Resource &gt; SpriteKit Particle File \u3092\u9078\u629e\u3059\u308b\u3002<br \/>\n<a href=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.28.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.28-300x202.png\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-09-25 7.30.28\" width=\"300\" height=\"202\" class=\"alignnone size-medium wp-image-3116\" srcset=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.28-300x202.png 300w, https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.28.png 732w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u305d\u3057\u305f\u3089\u6b21\u306b\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u30bf\u30a4\u30d7\u3092\u9078\u3076\u3002<br \/>\n\u4eca\u56de\u306f\u706b\u82b1\u3092\u6563\u3089\u305b\u305f\u3044\u306e\u3067 Spark \u306b\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.56.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.56-300x202.png\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-09-25 7.30.56\" width=\"300\" height=\"202\" class=\"alignnone size-medium wp-image-3117\" srcset=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.56-300x202.png 300w, https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.56.png 732w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u3067\u3001\u65b0\u3057\u304f\u8ffd\u52a0\u3055\u308c\u305fsks\u30d5\u30a1\u30a4\u30eb\uff08\u4eca\u56de\u306fMyParticle.sks\u3068\u3044\u3046\u540d\u524d\u306b\u3057\u305f\uff09\u3092\u898b\u3066\u307f\u308b\u3068\u3001\u52d5\u3044\u3066\u308b\u72b6\u614b\u306e\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u3092\u898b\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<br \/>\n<a href=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-8.44.12.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-8.44.12-300x196.jpg\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-09-25 8.44.12\" width=\"300\" height=\"196\" class=\"alignnone size-medium wp-image-3119\" srcset=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-8.44.12-300x196.jpg 300w, https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-8.44.12-1024x671.jpg 1024w, https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-8.44.12.jpg 1394w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u753b\u9762\u53f3\u5074\u306e Emitter Node \u30d1\u30cd\u30eb\u306e\u6570\u5024\u7b49\u3092\u3044\u3058\u308b\u3068\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u898b\u305f\u76ee\u3084\u52d5\u304d\u304c\u5909\u308f\u308b\u3002<br \/>\nParticle Texture \u3068\u3057\u3066 spark.png \u3068\u3044\u3046\u753b\u50cf\u304c\u4f7f\u7528\u3055\u308c\u3066\u3044\u308b\u304c\u3001\u3053\u308c\u306fsks\u30d5\u30a1\u30a4\u30eb\u3092\u8ffd\u52a0\u3057\u305f\u3068\u304d\u306b\u81ea\u52d5\u3067\u8ffd\u52a0\u3055\u308c\u308b\u306e\u3067\u3001\u81ea\u524d\u3067\u7528\u610f\u3059\u308b\u5fc5\u8981\u306f\u306a\u3044\u3002<br \/>\n\u3082\u3061\u308d\u3093\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u898b\u305f\u76ee\u3092\u5909\u3048\u308b\u305f\u3081\u306b\u30aa\u30ea\u30b8\u30ca\u30eb\u306e\u753b\u50cf\u306b\u5dee\u3057\u66ff\u3048\u308b\u4e8b\u3082\u51fa\u6765\u308b\u3002<\/p>\n<p>\u3042\u3068\u306f\u3053\u306e\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30fc\u30c9\u3067\u8aad\u307f\u8fbc\u3093\u3067\u3001\u30dc\u30fc\u30eb\u304c\u885d\u7a81\u3057\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u885d\u7a81\u3057\u305f\u5834\u6240\u306b\u8868\u793a\u3057\u3066\u3042\u3052\u308c\u3070\u3044\u3044\u3002<\/p>\n<h3>\u885d\u7a81\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3068\u4f4d\u7f6e<\/h3>\n<p>\u885d\u7a81\u3057\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u885d\u7a81\u306e\u60c5\u5831\u3092\u53d7\u3051\u53d6\u308b\u305f\u3081\u306b\u306f\u3001 SKPhysicsBody \u306e contactDelegate \u30d7\u30ed\u30d1\u30c6\u30a3\u306b SKPhysicsContactDelegate \u30d7\u30ed\u30c8\u30b3\u30eb\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u88c5\u3057\u305f\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u30bb\u30c3\u30c8\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<br \/>\n\u4eca\u56de\u306f\u7c21\u5358\u306e\u305f\u3081 MyScene \u30af\u30e9\u30b9\u306b SKPhysicsContactDelegate \u30d7\u30ed\u30c8\u30b3\u30eb\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u88c5\u3059\u308b\u3002<\/p>\n<p>\u307e\u305a\u3001 MyScene.h \u306b\u306f &lt;SKPhysicsContactDelegate&gt; \u3092\u8ffd\u52a0\u3057\u3066\u30d7\u30ed\u30c8\u30b3\u30eb\u6e96\u62e0\u3092\u793a\u3059\u3060\u3051\u3067\u3042\u308b\u3002<\/p>\n<pre class=\"brush: objc; title: ; notranslate\" title=\"\">#import &lt;SpriteKit\/SpriteKit.h&gt;\r\n\r\n@interface MyScene : SKScene &lt;SKPhysicsContactDelegate&gt;\r\n\r\n@end<\/pre>\n<p>\u305d\u3057\u305f\u3089\u3001 MyScene.m \u306b\u5b9f\u88c5\u3092\u66f8\u304f\u5fc5\u8981\u304c\u3042\u308b\u304c\u3001 SKPhysicsContactDelegate \u30d7\u30ed\u30c8\u30b3\u30eb\u306e\u30e1\u30bd\u30c3\u30c9\u306f -(void)didBeginContact:(SKPhysicsContact *)contact \u3068 -(void)didEndContact:(SKPhysicsContact *)contact \u306e2\u3064\u3057\u304b\u306a\u3044\u3002<br \/>\n\u305d\u308c\u305e\u308c\u885d\u7a81\u958b\u59cb\u6642\u3068\u885d\u7a81\u7d42\u4e86\u6642\u306b\u547c\u3070\u308c\u308b\u30e1\u30bd\u30c3\u30c9\u3060\u304c\u3001\u4eca\u56de\u306e\u3088\u3046\u306b\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u3092\u8868\u793a\u3059\u308b\u3060\u3051\u306a\u3089\u3069\u3061\u3089\u3092\u4f7f\u3063\u3066\u3082\u3042\u307e\u308a\u5dee\u306f\u7121\u3044\u3068\u601d\u3046\u3002<br \/>\n\u4eca\u56de\u306f didBeginContact \u3092\u4f7f\u3046\u3002<\/p>\n<pre class=\"brush: objc; title: ; notranslate\" title=\"\">-(void)didBeginContact:(SKPhysicsContact *)contact\r\n{\r\n    if (contact.collisionImpulse &gt; 10.0f) {\r\n        static SKEmitterNode* spark = nil;\r\n        if (!spark) {\r\n            NSString *path = &#x5B;&#x5B;NSBundle mainBundle] pathForResource:@&quot;MyParticle&quot; ofType:@&quot;sks&quot;];\r\n            spark = &#x5B;NSKeyedUnarchiver unarchiveObjectWithFile:path];\r\n            spark.position = contact.contactPoint;\r\n            spark.numParticlesToEmit = contact.collisionImpulse;\r\n            &#x5B;self addChild:spark];\r\n        } else {\r\n            spark.position = contact.contactPoint;\r\n            spark.numParticlesToEmit = contact.collisionImpulse;\r\n            &#x5B;spark resetSimulation];\r\n        }\r\n    }\r\n}\r\n\r\n-(void)didEndContact:(SKPhysicsContact *)contact\r\n{\r\n\r\n}<\/pre>\n<p>SKPhysicsContact \u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u3042\u308b contact \u304b\u3089\u306f\u3001\u3076\u3064\u304b\u3063\u305f2\u3064\u306e\u525b\u4f53\u3078\u306e\u53c2\u7167\u3084\u3001\u885d\u7a81\u6642\u306e\u885d\u6483\uff08\u5358\u4f4d\u306f\u30cb\u30e5\u30fc\u30c8\u30f3\u79d2\uff09\u3001\u885d\u7a81\u70b9\uff08\u30b9\u30af\u30ea\u30fc\u30f3\u5ea7\u6a19\u306b\u304a\u3051\u308b\u4f4d\u7f6e\uff09\u306e\u60c5\u5831\u3092\u5f97\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<\/p>\n<p>\u4e0a\u306e\u30b3\u30fc\u30c9\u3067\u306f\u307e\u305a\u3001\u885d\u6483\u304c10\u30cb\u30e5\u30fc\u30c8\u30f3\u79d2\u3088\u308a\u5927\u304d\u3044\u5834\u5408\u306b\u3001sks\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3001\u885d\u7a81\u70b9\u306b\u885d\u7a81\u6642\u306e\u885d\u6483\u306b\u5fdc\u3058\u305f\u6570\u306e\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u3092\u751f\u6210\u3057\u3066\u3044\u308b\u3002<br \/>\n\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u751f\u6210\u306b\u306f SKEmitterNode \u3092\u4f7f\u3063\u3066\u3044\u308b\u304c\u3001\u305d\u306e position \u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u751f\u6210\u4f4d\u7f6e\u3092\u3001 numParticlesToEmit \u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u751f\u6210\u6570\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<\/p>\n<p>SKEmitterNode \u306e\u751f\u6210\u3068\u30b7\u30fc\u30f3\u3078\u306e addChild \u3092\u521d\u56de\u3060\u3051\u884c\u3046\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306bstatic\u5909\u6570\u3068if\u3092\u4f7f\u3063\u3066\u308b\u3053\u3068\u306b\u6ce8\u610f\u3002<br \/>\n\u8aac\u660e\u3092\u7c21\u5358\u306b\u3059\u308b\u305f\u3081\u306b\u4eca\u56de\u306fstatic\u5909\u6570\u3092\u4f7f\u3063\u305f\u304c\u3001\u30e1\u30f3\u30d0\u5909\u6570\u306b\u3057\u305f\u308a\u3059\u3079\u304d\u3060\u308d\u3046\u3002<\/p>\n<p>\u521d\u56de\u306f\u3001 [self addChild:spark]; \u3057\u305f\u6642\u70b9\u3067\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u751f\u6210\u304c\u958b\u59cb\u3055\u308c\u30012\u56de\u76ee\u4ee5\u964d\u306f [spark resetSimulation]; \u3067\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u304c\u518d\u5ea6\u751f\u6210\u3055\u308c\u308b\u3002<br \/>\nSKEmitterNode \u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3072\u3068\u3064\u3092\u4f7f\u3044\u56de\u3057\u3066\u308b\u305f\u3081\u3001\u77ed\u6642\u9593\u306b\u9023\u7d9a\u3067\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u3092\u751f\u6210\u3059\u308b\u3068\u706b\u82b1\u304c\u5e83\u304c\u308a\u304d\u308b\u524d\u306b\u6b21\u306e\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u751f\u6210\u306b\u3088\u3063\u3066\u6d88\u3048\u3066\u3057\u307e\u3046\u70b9\u306b\u6ce8\u610f\u3002<br \/>\n\u3053\u306e\u554f\u984c\u3092\u8efd\u6e1b\u3059\u308b\u306b\u306f\u3001 SKEmitterNode \u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u914d\u5217\u306a\u3069\u3067\u8907\u6570\u6301\u3061\u3001\u305d\u308c\u3089\u3092\u9806\u756a\u306b\u4f7f\u3046\u3088\u3046\u306b\u3059\u308b\u3068\u3044\u3044\u3060\u308d\u3046\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b numParticlesToEmit \u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306f0\u3068\u306a\u3063\u3066\u304a\u308a\u3001\u305d\u306e\u307e\u307e\u3060\u3068\u7121\u9650\u306b\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u304c\u751f\u6210\u3055\u308c\u7d9a\u3051\u308b\u306e\u3067\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3042\u308b\u3002<br \/>\n\u3042\u3068\u3001GUI\u3067\u8a2d\u5b9a\u51fa\u6765\u308bsks\u30d5\u30a1\u30a4\u30eb\u306e\u9805\u76ee\u306f SKEmitterNode \u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3068\u3057\u3066\u3082\u7528\u610f\u3055\u308c\u3066\u308b\u306e\u3067\u3001\u30b3\u30fc\u30c9\u304b\u3089\u3082\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u898b\u305f\u76ee\u3092\u8272\u3005\u3044\u3058\u308c\u308b\u306f\u305a\u3067\u3042\u308b\u3002\uff08\u672a\u78ba\u8a8d\uff09<\/p>\n<p>\u3053\u308c\u3067\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u8868\u793a\u306e\u4ed5\u65b9\u306f\u5206\u304b\u3063\u305f\u304c\u3001\u5b9f\u306f\u3053\u306e\u72b6\u614b\u3067\u5b9f\u884c\u3057\u3066\u3082\u307e\u3060\u4f55\u3082\u8d77\u3053\u3089\u306a\u3044\uff08didBeginContact\u304c\u547c\u3070\u308c\u306a\u3044\uff09\u3002<\/p>\n<h3>\u885d\u7a81\u30c7\u30ea\u30b2\u30fc\u30c8\u306e\u8a2d\u5b9a<\/h3>\n<p>\u885d\u7a81\u304c\u8d77\u304d\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067 didBeginContact \u3084 didEndContact \u3092\u547c\u3070\u308c\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u3001\u307e\u305a SKPhysicsWorld \u306e contactDelegate \u3092\u30bb\u30c3\u30c8\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<br \/>\n<a href=\"https:\/\/peta.okechan.net\/blog\/archives\/3084\" title=\"SpriteKit\u3092\u4f7f\u3063\u3066\u307f\u308b \u305d\u306e2\">\u524d\u56de<\/a>\u306e initWithSize \u30e1\u30bd\u30c3\u30c9\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u308b\u3002<\/p>\n<pre class=\"brush: objc; title: ; notranslate\" title=\"\">-(id)initWithSize:(CGSize)size {   \r\n    if (self = &#x5B;super initWithSize:size]) {\r\n        \/* Setup your scene here *\/\r\n         \r\n        self.backgroundColor = &#x5B;SKColor colorWithRed:0.15 green:0.15 blue:0.3 alpha:1.0];\r\n         \r\n        SKLabelNode *myLabel = &#x5B;SKLabelNode labelNodeWithFontNamed:@&quot;Chalkduster&quot;];\r\n         \r\n        myLabel.text = @&quot;Hello, World!&quot;;\r\n        myLabel.fontSize = 30;\r\n        myLabel.position = CGPointMake(CGRectGetMidX(self.frame),\r\n                                       CGRectGetMidY(self.frame));\r\n         \r\n        &#x5B;self addChild:myLabel];\r\n         \r\n        self.physicsBody = &#x5B;SKPhysicsBody bodyWithEdgeLoopFromRect:(CGRect){CGPointZero, size}];\r\n        self.physicsWorld.contactDelegate = self;\r\n    }\r\n    return self;\r\n}<\/pre>\n<p>self.physicsWorld.contactDelegate = self; \u306e\u884c\u3092\u8ffd\u52a0\u3057\u305f\u3060\u3051\u3067\u3042\u308b\u3002<br \/>\n\u3053\u3053\u3067\u3044\u3046 self \u306f \u4e0a\u3067 SKPhysicsContactDelegate \u30d7\u30ed\u30c8\u30b3\u30eb\u3092\u5b9f\u88c5\u3057\u305f MyScene \u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306a\u306e\u3067\u3053\u308c\u304c\u53ef\u80fd\u3068\u306a\u3063\u3066\u3044\u308b\u3002<br \/>\n\u3053\u308c\u3067 didBeginContact \u304c\u547c\u3070\u308c\u308b\u3001\u3088\u3046\u306b\u306a\u308c\u3070\u697d\u306a\u3093\u3060\u304c\u3001\u3082\u3046\u3072\u3068\u624b\u9593\uff08\u3082\u3046\u3072\u3068\u7406\u89e3\uff09\u304c\u5fc5\u8981\u3067\u3042\u308b\u3002<\/p>\n<h3>\u885d\u7a81\u30c6\u30b9\u30c8\u30d3\u30c3\u30c8\u30de\u30b9\u30af\u306e\u8a2d\u5b9a<\/h3>\n<p>\u7b54\u3048\u3092\u8a00\u3063\u3066\u3057\u307e\u3048\u3070\u3001 SKPhysicsBody \u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\u3057\u305f\u969b\u306b\u305d\u306e contactTestBitMask \u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u5e38\u306b1\u3092\u30bb\u30c3\u30c8\u3059\u308c\u3070\u3044\u3044\u3002<br \/>\n<a href=\"https:\/\/peta.okechan.net\/blog\/archives\/3084\" title=\"SpriteKit\u3092\u4f7f\u3063\u3066\u307f\u308b \u305d\u306e2\">\u524d\u56de<\/a>\u306e touchesBegan \u30e1\u30bd\u30c3\u30c9\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u308b\u3002<\/p>\n<pre class=\"brush: objc; title: ; notranslate\" title=\"\">-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {\r\n    \/* Called when a touch begins *\/\r\n     \r\n    for (UITouch *touch in touches) {\r\n        CGPoint location = &#x5B;touch locationInNode:self];\r\n         \r\n        SKSpriteNode *sprite = &#x5B;SKSpriteNode spriteNodeWithImageNamed:@&quot;Ball&quot;];\r\n         \r\n        sprite.position = location;\r\n         \r\n        const CGFloat radius = 20.0f;\r\n        SKPhysicsBody *pbody = &#x5B;SKPhysicsBody bodyWithCircleOfRadius:radius];\r\n        pbody.contactTestBitMask = 1;\r\n        sprite.physicsBody = pbody;\r\n        sprite.size = (CGSize){radius * 2, radius * 2};\r\n         \r\n        &#x5B;self addChild:sprite];\r\n    }\r\n}<\/pre>\n<p>pbody.contactTestBitMask = 1; \u306e\u884c\u3092\u8ffd\u52a0\u3057\u305f\u3060\u3051\u3067\u3042\u308b\u3002<br \/>\n\u3053\u308c\u3067 didBeginContact \u30e1\u30bd\u30c3\u30c9\u304c\u547c\u3070\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u3001\u885d\u7a81\u70b9\u304b\u3089\u706b\u82b1\u304c\u6563\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u306f\u305a\u3067\u3042\u308b\u3002<\/p>\n<p>\u306a\u305c\u3053\u308c\u3060\u3051\u3067\u826f\u3044\u306e\u304b\u3092\u77e5\u308b\u305f\u3081\u306b\u306b\u306f\u3001\u3082\u3046\u3072\u3068\u3064\u306e\u30d3\u30c3\u30c8\u30de\u30b9\u30af\u3067\u3042\u308b categoryBitMask \u306b\u3064\u3044\u3066\u77e5\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<br \/>\ncategoryBitMask \u306f\u305d\u306e\u525b\u4f53\u304c\u3069\u306e\u30ab\u30c6\u30b4\u30ea\u306b\u5c5e\u3059\u308b\u304b\u3092\u8868\u3059\u30d3\u30c3\u30c8\u5024\u3067\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306f0xffffffff\u3067\u3042\u308b\u3002<\/p>\n<p>SKPhysicsWorld \u306e\u5185\u90e8\u3067\u306f\u3001\u525b\u4f53\u540c\u58eb\u304c\u3076\u3064\u304b\u3063\u305f\u5834\u5408\u306b\u3001\u7247\u65b9\u306e\u525b\u4f53\u306e contactTestBitMask \u3068\u3082\u3046\u7247\u65b9\u306e categoryBitMask \u3067\u8ad6\u7406\u7a4d\uff08AND\uff09\u3092\u3068\u308a\u3001\u305d\u306e\u7d50\u679c\u304c0\u3067\u306a\u3051\u308c\u3070  SKPhysicsContact \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u751f\u6210\u3057\u3001\u30c7\u30ea\u30b2\u30fc\u30c8\u306e didBeginContact \u30e1\u30bd\u30c3\u30c9\u306a\u3069\u304c\u547c\u3070\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3002<br \/>\ncontactTestBitMask \u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306f0x00000000\u306a\u306e\u3067\u3001\u305d\u306e\u307e\u307e\u3060\u3068 didBeginContact \u30e1\u30bd\u30c3\u30c9\u306a\u3069\u304c\u3088\u3070\u308c\u308b\u4e8b\u306f\u4e00\u5207\u7121\u3044\u3002<br \/>\n\u624b\u8efd\u3055\u3092\u5fd7\u5411\u3057\u3066\u3044\u308bSpriteKit\u306b\u304a\u3044\u3066\u306f\u3001\u73cd\u3057\u304f\u9762\u5012\u306a\u4ed5\u69d8\u3060\u304c\u3001\u885d\u7a81\u5224\u5b9a\u304b\u3089\u885d\u7a81\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u751f\u6210\u3001\u30c7\u30ea\u30b2\u30fc\u30c8\u30e1\u30bd\u30c3\u30c9\u547c\u3073\u51fa\u3057\u306e\u4e00\u9023\u306e\u51e6\u7406\u304c\u6bd4\u8f03\u7684\u91cd\u3044\u306e\u3067\u3053\u3046\u3044\u3046\u4ed5\u69d8\u306b\u306a\u3063\u3066\u3044\u308b\u3088\u3046\u3067\u3042\u308b\u3002<\/p>\n<p>contactTestBitMask \u306f\u305d\u306e\u540d\u306e\u3068\u304a\u308a\u30d3\u30c3\u30c8\u30de\u30b9\u30af\u306a\u306e\u3067\u3001\u4f8b\u3048\u3070\u525b\u4f53A\uff08\u6575A\uff09\u3068\u525b\u4f53B\uff08\u6575B\uff09\u540c\u58eb\u306b\u95a2\u3057\u3066\u306f\u7279\u5225\u306a\u885d\u7a81\u6642\u306e\u51e6\u7406\u306f\u5fc5\u8981\u306a\u3044\u304c\u3001\u525b\u4f53C\uff08\u30d7\u30ec\u30a4\u30e4\u30fc\uff09\u3068\u525b\u4f53A\u3082\u3057\u304f\u306f\u525b\u4f53B\u306e\u885d\u7a81\u6642\u306b\u306f\u7279\u5225\u306a\u51e6\u7406\u3092\u884c\u3044\u305f\u3044\u3068\u3044\u3046\u3088\u3046\u306a\u5834\u5408\u306b\u3082\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8a2d\u5b9a\u306b\u3059\u308c\u3070\u5bfe\u5fdc\u51fa\u6765\u308b\u3002<\/p>\n<pre class=\"brush: objc; title: ; notranslate\" title=\"\">player.categoryBitMask = 1;\r\nenemyA.categoryBitMask = 2;\r\nenemyB.categoryBitMask = 2;\r\n\r\nplayer.contactTestBitMask = 2;\r\nenemyA.contactTestBitMask = 1;\r\nenemyA.contactTestBitMask = 1;<\/pre>\n<p>\u5b9f\u306f\u3001 SKPhysicsBody \u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306b BitMask \u3068\u4ed8\u304f\u3082\u306e\u304c\u3082\u3046\u3072\u3068\u3064\u3042\u308b\u3002<br \/>\ncollisionBitMask \u3067\u3042\u308b\u3002<\/p>\n<p>collisionBitMask \u306f\u3069\u306e\u30ab\u30c6\u30b4\u30ea\u306e\u525b\u4f53\u3068\u885d\u7a81\u3059\u308b\u304b\u3092\u6307\u5b9a\u3059\u308b\u305f\u3081\u306e\u30d3\u30c3\u30c8\u30de\u30b9\u30af\u3067\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306f0xffffffff\u3068\u306a\u3063\u3066\u3044\u308b\u3002<br \/>\n2\u3064\u306e\u525b\u4f53\u306e collisionBitMask \u3068 categoryBitMask \u3067\u8ad6\u7406\u7a4d\u3092\u3068\u3063\u305f\u7d50\u679c\u304c0\u306b\u306a\u308b\u3068\u305d\u306e\u525b\u4f53\u540c\u58eb\u306f\u3059\u308a\u629c\u3051\u308b\u3002<\/p>\n<h3>\u304a\u308f\u308a\u306b<\/h3>\n<p>SpriteKit\u306e\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u7c21\u5358\u306a\u30a2\u30d7\u30ea\u3092\u4f5c\u308a\u306a\u304c\u3089\u898b\u3066\u304d\u305f\u304c\u3001\u975e\u5e38\u306b\u7c21\u5358\u306b\u4f7f\u3048\u308b\u4e8b\u304c\u5206\u304b\u3063\u305f\u3068\u601d\u3046\u3002<br \/>\n\u3057\u304b\u3057\u307e\u3060\u30b5\u30a6\u30f3\u30c9\u95a2\u9023\u3084\u30a2\u30af\u30b7\u30e7\u30f3\u95a2\u9023\u3001\u3042\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5468\u308a\u306f\u5168\u7136\u898b\u3066\u3044\u306a\u3044\u3002<br \/>\n\u305d\u306e\u8fba\u308a\u3082\u8abf\u3079\u305f\u3089\u8a18\u4e8b\u3092\u66f8\u304f\u304b\u3082\u3057\u308c\u306a\u3044\u304c\u3001\u591a\u5206\u4eca\u56de\u306e\u3088\u3046\u306b\u3061\u3083\u3093\u3068\u306f\u66f8\u304b\u306a\u3044\u3060\u308d\u3046\uff08\u75b2\u308c\u308b\u306e\u3067w\uff09\u3002<\/p>\n<p>SpriteKit\u3067\u3001\u30b2\u30fc\u30e0\u4f5c\u6210\u8005\u4eba\u53e3\u304c\u5897\u3048\u308b\u3068\u3044\u3044\u306a\u3041(*\u00b4\u2200\uff40*)\uff8e\uff9f\uff9c\uff9c<\/p>\n","protected":false},"excerpt":{"rendered":"<p><a href=\"https:\/\/peta.okechan.net\/blog\/archives\/3084\" title=\"SpriteKit\u3092\u4f7f\u3063\u3066\u307f\u308b \u305d\u306e2\">\u524d\u56de<\/a>\u3001SpriteKit\u306e\u7269\u7406\u30a8\u30f3\u30b8\u30f3\u3092\u5229\u7528\u3057\u305f\u7c21\u5358\u306a\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3057\u305f\u3002<br \/>\n\u4eca\u56de\u306f\u305d\u306e\u30a2\u30d7\u30ea\u306b\u3001SpriteKit\u306e\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u30b7\u30b9\u30c6\u30e0\u3092\u5229\u7528\u3057\u305f\u3061\u3087\u3063\u3068\u3057\u305f\u30a8\u30d5\u30a7\u30af\u30c8\u3092\u8ffd\u52a0\u3057\u3066\u307f\u308b\u3002<\/p>\n<h3>\u76ee\u6a19<\/h3>\n<p>\u30dc\u30fc\u30eb\u306b\u3042\u308b\u4e00\u5b9a\u4ee5\u4e0a\u306e\u885d\u6483\u304c\u52a0\u308f\u3063\u305f\u3089\u706b\u82b1\u3092\u6563\u3089\u3059\u3002<br \/>\n\u4eca\u56de\u306e\u5834\u5408\u3060\u3068\u3001\u30dc\u30fc\u30eb\u304c\u753b\u9762\u306e\u67a0\u3084\u30dc\u30fc\u30eb\u540c\u58eb\u3067\u3076\u3064\u304b\u3063\u305f\u3068\u304d\u306b\u706b\u82b1\u304c\u767a\u751f\u3059\u308b\u3088\u3046\u306b\u306a\u308b\u3002<br \/>\n<a href=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.51.02.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.51.02-180x300.png\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-09-25 7.51.02\" width=\"180\" height=\"300\" class=\"alignnone size-medium wp-image-3114\" srcset=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.51.02-180x300.png 180w, https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.51.02.png 594w\" sizes=\"auto, (max-width: 180px) 100vw, 180px\" \/><\/a><\/p>\n<h3>\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u30c7\u30b6\u30a4\u30f3<\/h3>\n<p>\u3069\u3046\u3044\u3046\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306b\u3059\u308b\u304b\u306f\u30b3\u30fc\u30c9\u3067\u3082\u6307\u5b9a\u3067\u304d\u308b\u304c\u3001Xcode 5\u304b\u3089SpriteKit\u306e\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u3092GUI\u3067\u30c7\u30b6\u30a4\u30f3\u3067\u304d\u308b\u6a5f\u80fd\u304c\u8ffd\u52a0\u3055\u308c\u305f\u306e\u3067\u3001\u305d\u308c\u3092\u4f7f\u3063\u3066\u307f\u308b\u3002<\/p>\n<p>\u307e\u305a\u3001\u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u306e\u8ffd\u52a0\u3067 Resource &gt; SpriteKit Particle File \u3092\u9078\u629e\u3059\u308b\u3002<br \/>\n<a href=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.28.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.28-300x202.png\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-09-25 7.30.28\" width=\"300\" height=\"202\" class=\"alignnone size-medium wp-image-3116\" srcset=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.28-300x202.png 300w, https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.28.png 732w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u305d\u3057\u305f\u3089\u6b21\u306b\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u30bf\u30a4\u30d7\u3092\u9078\u3076\u3002<br \/>\n\u4eca\u56de\u306f\u706b\u82b1\u3092\u6563\u3089\u305b\u305f\u3044\u306e\u3067 Spark \u306b\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.56.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.56-300x202.png\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-09-25 7.30.56\" width=\"300\" height=\"202\" class=\"alignnone size-medium wp-image-3117\" srcset=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.56-300x202.png 300w, https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-7.30.56.png 732w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u3067\u3001\u65b0\u3057\u304f\u8ffd\u52a0\u3055\u308c\u305fsks\u30d5\u30a1\u30a4\u30eb\uff08\u4eca\u56de\u306fMyParticle.sks\u3068\u3044\u3046\u540d\u524d\u306b\u3057\u305f\uff09\u3092\u898b\u3066\u307f\u308b\u3068\u3001\u52d5\u3044\u3066\u308b\u72b6\u614b\u306e\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u3092\u898b\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<br \/>\n<a href=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-8.44.12.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-8.44.12-300x196.jpg\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-09-25 8.44.12\" width=\"300\" height=\"196\" class=\"alignnone size-medium wp-image-3119\" srcset=\"https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-8.44.12-300x196.jpg 300w, https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-8.44.12-1024x671.jpg 1024w, https:\/\/peta.okechan.net\/blog\/wp-content\/uploads\/2013\/09\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2013-09-25-8.44.12.jpg 1394w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u753b\u9762\u53f3\u5074\u306e Emitter Node \u30d1\u30cd\u30eb\u306e\u6570\u5024\u7b49\u3092\u3044\u3058\u308b\u3068\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u898b\u305f\u76ee\u3084\u52d5\u304d\u304c\u5909\u308f\u308b\u3002<br \/>\nParticle Texture \u3068\u3057\u3066 spark.png \u3068\u3044\u3046\u753b\u50cf\u304c\u4f7f\u7528\u3055\u308c\u3066\u3044\u308b\u304c\u3001\u3053\u308c\u306fsks\u30d5\u30a1\u30a4\u30eb\u3092\u8ffd\u52a0\u3057\u305f\u3068\u304d\u306b\u81ea\u52d5\u3067\u8ffd\u52a0\u3055\u308c\u308b\u306e\u3067\u3001\u81ea\u524d\u3067\u7528\u610f\u3059\u308b\u5fc5\u8981\u306f\u306a\u3044\u3002<br \/>\n\u3082\u3061\u308d\u3093\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u898b\u305f\u76ee\u3092\u5909\u3048\u308b\u305f\u3081\u306b\u30aa\u30ea\u30b8\u30ca\u30eb\u306e\u753b\u50cf\u306b\u5dee\u3057\u66ff\u3048\u308b\u4e8b\u3082\u51fa\u6765\u308b\u3002<\/p>\n<p>\u3042\u3068\u306f\u3053\u306e\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30fc\u30c9\u3067\u8aad\u307f\u8fbc\u3093\u3067\u3001\u30dc\u30fc\u30eb\u304c\u885d\u7a81\u3057\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u885d\u7a81\u3057\u305f\u5834\u6240\u306b\u8868\u793a\u3057\u3066\u3042\u3052\u308c\u3070\u3044\u3044\u3002<\/p>\n<h3>\u885d\u7a81\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3068\u4f4d\u7f6e<\/h3>\n<p>\u885d\u7a81\u3057\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u885d\u7a81\u306e\u60c5\u5831\u3092\u53d7\u3051\u53d6\u308b\u305f\u3081\u306b\u306f\u3001 SKPhysicsBody \u306e contactDelegate \u30d7\u30ed\u30d1\u30c6\u30a3\u306b SKPhysicsContactDelegate \u30d7\u30ed\u30c8\u30b3\u30eb\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u88c5\u3057\u305f\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u30bb\u30c3\u30c8\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<br \/>\n\u4eca\u56de\u306f\u7c21\u5358\u306e\u305f\u3081 MyScene \u30af\u30e9\u30b9\u306b SKPhysicsContactDelegate \u30d7\u30ed\u30c8\u30b3\u30eb\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u88c5\u3059\u308b\u3002<\/p>\n<p>\u307e\u305a\u3001 MyScene.h \u306b\u306f &lt;SKPhysicsContactDelegate&gt; \u3092\u8ffd\u52a0\u3057\u3066\u30d7\u30ed\u30c8\u30b3\u30eb\u6e96\u62e0\u3092\u793a\u3059\u3060\u3051\u3067\u3042\u308b\u3002<\/p>\n<pre class=\"brush: objc; title: ; notranslate\" title=\"\">#import &lt;SpriteKit\/SpriteKit.h&gt;\r\n\r\n@interface MyScene : SKScene &lt;SKPhysicsContactDelegate&gt;\r\n\r\n@end<\/pre>\n<p>\u305d\u3057\u305f\u3089\u3001 MyScene.m \u306b\u5b9f\u88c5\u3092\u66f8\u304f\u5fc5\u8981\u304c\u3042\u308b\u304c\u3001 SKPhysicsContactDelegate \u30d7\u30ed\u30c8\u30b3\u30eb\u306e\u30e1\u30bd\u30c3\u30c9\u306f -(void)didBeginContact:(SKPhysicsContact *)contact \u3068 -(void)didEndContact:(SKPhysicsContact *)contact \u306e2\u3064\u3057\u304b\u306a\u3044\u3002<br \/>\n\u305d\u308c\u305e\u308c\u885d\u7a81\u958b\u59cb\u6642\u3068\u885d\u7a81\u7d42\u4e86\u6642\u306b\u547c\u3070\u308c\u308b\u30e1\u30bd\u30c3\u30c9\u3060\u304c\u3001\u4eca\u56de\u306e\u3088\u3046\u306b\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u3092\u8868\u793a\u3059\u308b\u3060\u3051\u306a\u3089\u3069\u3061\u3089\u3092\u4f7f\u3063\u3066\u3082\u3042\u307e\u308a\u5dee\u306f\u7121\u3044\u3068\u601d\u3046\u3002<br \/>\n\u4eca\u56de\u306f didBeginContact \u3092\u4f7f\u3046\u3002<\/p>\n<pre class=\"brush: objc; title: ; notranslate\" title=\"\">-(void)didBeginContact:(SKPhysicsContact *)contact\r\n{\r\n    if (contact.collisionImpulse &gt; 10.0f) {\r\n        static SKEmitterNode* spark = nil;\r\n        if (!spark) {\r\n            NSString *path = &#x5B;&#x5B;NSBundle mainBundle] pathForResource:@&quot;MyParticle&quot; ofType:@&quot;sks&quot;];\r\n            spark = &#x5B;NSKeyedUnarchiver unarchiveObjectWithFile:path];\r\n            spark.position = contact.contactPoint;\r\n            spark.numParticlesToEmit = contact.collisionImpulse;\r\n            &#x5B;self addChild:spark];\r\n        } else {\r\n            spark.position = contact.contactPoint;\r\n            spark.numParticlesToEmit = contact.collisionImpulse;\r\n            &#x5B;spark resetSimulation];\r\n        }\r\n    }\r\n}\r\n\r\n-(void)didEndContact:(SKPhysicsContact *)contact\r\n{\r\n\r\n}<\/pre>\n<p>SKPhysicsContact \u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u3042\u308b contact \u304b\u3089\u306f\u3001\u3076\u3064\u304b\u3063\u305f2\u3064\u306e\u525b\u4f53\u3078\u306e\u53c2\u7167\u3084\u3001\u885d\u7a81\u6642\u306e\u885d\u6483\uff08\u5358\u4f4d\u306f\u30cb\u30e5\u30fc\u30c8\u30f3\u79d2\uff09\u3001\u885d\u7a81\u70b9\uff08\u30b9\u30af\u30ea\u30fc\u30f3\u5ea7\u6a19\u306b\u304a\u3051\u308b\u4f4d\u7f6e\uff09\u306e\u60c5\u5831\u3092\u5f97\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<\/p>\n<p>\u4e0a\u306e\u30b3\u30fc\u30c9\u3067\u306f\u307e\u305a\u3001\u885d\u6483\u304c10\u30cb\u30e5\u30fc\u30c8\u30f3\u79d2\u3088\u308a\u5927\u304d\u3044\u5834\u5408\u306b\u3001sks\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3001\u885d\u7a81\u70b9\u306b\u885d\u7a81\u6642\u306e\u885d\u6483\u306b\u5fdc\u3058\u305f\u6570\u306e\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u3092\u751f\u6210\u3057\u3066\u3044\u308b\u3002<br \/>\n\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u751f\u6210\u306b\u306f SKEmitterNode \u3092\u4f7f\u3063\u3066\u3044\u308b\u304c\u3001\u305d\u306e position \u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u751f\u6210\u4f4d\u7f6e\u3092\u3001 numParticlesToEmit \u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u751f\u6210\u6570\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002<\/p>\n<p>SKEmitterNode \u306e\u751f\u6210\u3068\u30b7\u30fc\u30f3\u3078\u306e addChild \u3092\u521d\u56de\u3060\u3051\u884c\u3046\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306bstatic\u5909\u6570\u3068if\u3092\u4f7f\u3063\u3066\u308b\u3053\u3068\u306b\u6ce8\u610f\u3002<br \/>\n\u8aac\u660e\u3092\u7c21\u5358\u306b\u3059\u308b\u305f\u3081\u306b\u4eca\u56de\u306fstatic\u5909\u6570\u3092\u4f7f\u3063\u305f\u304c\u3001\u30e1\u30f3\u30d0\u5909\u6570\u306b\u3057\u305f\u308a\u3059\u3079\u304d\u3060\u308d\u3046\u3002<\/p>\n<p>\u521d\u56de\u306f\u3001 [self addChild:spark]; \u3057\u305f\u6642\u70b9\u3067\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u751f\u6210\u304c\u958b\u59cb\u3055\u308c\u30012\u56de\u76ee\u4ee5\u964d\u306f [spark resetSimulation]; \u3067\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u304c\u518d\u5ea6\u751f\u6210\u3055\u308c\u308b\u3002<br \/>\nSKEmitterNode \u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3072\u3068\u3064\u3092\u4f7f\u3044\u56de\u3057\u3066\u308b\u305f\u3081\u3001\u77ed\u6642\u9593\u306b\u9023\u7d9a\u3067\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u3092\u751f\u6210\u3059\u308b\u3068\u706b\u82b1\u304c\u5e83\u304c\u308a\u304d\u308b\u524d\u306b\u6b21\u306e\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u751f\u6210\u306b\u3088\u3063\u3066\u6d88\u3048\u3066\u3057\u307e\u3046\u70b9\u306b\u6ce8\u610f\u3002<br \/>\n\u3053\u306e\u554f\u984c\u3092\u8efd\u6e1b\u3059\u308b\u306b\u306f\u3001 SKEmitterNode \u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u914d\u5217\u306a\u3069\u3067\u8907\u6570\u6301\u3061\u3001\u305d\u308c\u3089\u3092\u9806\u756a\u306b\u4f7f\u3046\u3088\u3046\u306b\u3059\u308b\u3068\u3044\u3044\u3060\u308d\u3046\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b numParticlesToEmit \u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306f0\u3068\u306a\u3063\u3066\u304a\u308a\u3001\u305d\u306e\u307e\u307e\u3060\u3068\u7121\u9650\u306b\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u304c\u751f\u6210\u3055\u308c\u7d9a\u3051\u308b\u306e\u3067\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3042\u308b\u3002<br \/>\n\u3042\u3068\u3001GUI\u3067\u8a2d\u5b9a\u51fa\u6765\u308bsks\u30d5\u30a1\u30a4\u30eb\u306e\u9805\u76ee\u306f SKEmitterNode \u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3068\u3057\u3066\u3082\u7528\u610f\u3055\u308c\u3066\u308b\u306e\u3067\u3001\u30b3\u30fc\u30c9\u304b\u3089\u3082\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u898b\u305f\u76ee\u3092\u8272\u3005\u3044\u3058\u308c\u308b\u306f\u305a\u3067\u3042\u308b\u3002\uff08\u672a\u78ba\u8a8d\uff09<\/p>\n<p>\u3053\u308c\u3067\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u8868\u793a\u306e\u4ed5\u65b9\u306f\u5206\u304b\u3063\u305f\u304c\u3001\u5b9f\u306f\u3053\u306e\u72b6\u614b\u3067\u5b9f\u884c\u3057\u3066\u3082\u307e\u3060\u4f55\u3082\u8d77\u3053\u3089\u306a\u3044\uff08didBeginContact\u304c\u547c\u3070\u308c\u306a\u3044\uff09\u3002<\/p>\n<h3>\u885d\u7a81\u30c7\u30ea\u30b2\u30fc\u30c8\u306e\u8a2d\u5b9a<\/h3>\n<p>\u885d\u7a81\u304c\u8d77\u304d\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067 didBeginContact \u3084 didEndContact \u3092\u547c\u3070\u308c\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u3001\u307e\u305a SKPhysicsWorld \u306e contactDelegate \u3092\u30bb\u30c3\u30c8\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<br \/>\n<a href=\"https:\/\/peta.okechan.net\/blog\/archives\/3084\" title=\"SpriteKit\u3092\u4f7f\u3063\u3066\u307f\u308b \u305d\u306e2\">\u524d\u56de<\/a>\u306e initWithSize \u30e1\u30bd\u30c3\u30c9\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u308b\u3002<\/p>\n<pre class=\"brush: objc; title: ; notranslate\" title=\"\">-(id)initWithSize:(CGSize)size {   \r\n    if (self = &#x5B;super initWithSize:size]) {\r\n        \/* Setup your scene here *\/\r\n         \r\n        self.backgroundColor = &#x5B;SKColor colorWithRed:0.15 green:0.15 blue:0.3 alpha:1.0];\r\n         \r\n        SKLabelNode *myLabel = &#x5B;SKLabelNode labelNodeWithFontNamed:@&quot;Chalkduster&quot;];\r\n         \r\n        myLabel.text = @&quot;Hello, World!&quot;;\r\n        myLabel.fontSize = 30;\r\n        myLabel.position = CGPointMake(CGRectGetMidX(self.frame),\r\n                                       CGRectGetMidY(self.frame));\r\n         \r\n        &#x5B;self addChild:myLabel];\r\n         \r\n        self.physicsBody = &#x5B;SKPhysicsBody bodyWithEdgeLoopFromRect:(CGRect){CGPointZero, size}];\r\n        self.physicsWorld.contactDelegate = self;\r\n    }\r\n    return self;\r\n}<\/pre>\n<p>self.physicsWorld.contactDelegate = self; \u306e\u884c\u3092\u8ffd\u52a0\u3057\u305f\u3060\u3051\u3067\u3042\u308b\u3002<br \/>\n\u3053\u3053\u3067\u3044\u3046 self \u306f \u4e0a\u3067 SKPhysicsContactDelegate \u30d7\u30ed\u30c8\u30b3\u30eb\u3092\u5b9f\u88c5\u3057\u305f MyScene \u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306a\u306e\u3067\u3053\u308c\u304c\u53ef\u80fd\u3068\u306a\u3063\u3066\u3044\u308b\u3002<br \/>\n\u3053\u308c\u3067 didBeginContact \u304c\u547c\u3070\u308c\u308b\u3001\u3088\u3046\u306b\u306a\u308c\u3070\u697d\u306a\u3093\u3060\u304c\u3001\u3082\u3046\u3072\u3068\u624b\u9593\uff08\u3082\u3046\u3072\u3068\u7406\u89e3\uff09\u304c\u5fc5\u8981\u3067\u3042\u308b\u3002<\/p>\n<h3>\u885d\u7a81\u30c6\u30b9\u30c8\u30d3\u30c3\u30c8\u30de\u30b9\u30af\u306e\u8a2d\u5b9a<\/h3>\n<p>\u7b54\u3048\u3092\u8a00\u3063\u3066\u3057\u307e\u3048\u3070\u3001 SKPhysicsBody \u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\u3057\u305f\u969b\u306b\u305d\u306e contactTestBitMask \u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u5e38\u306b1\u3092\u30bb\u30c3\u30c8\u3059\u308c\u3070\u3044\u3044\u3002<br \/>\n<a href=\"https:\/\/peta.okechan.net\/blog\/archives\/3084\" title=\"SpriteKit\u3092\u4f7f\u3063\u3066\u307f\u308b \u305d\u306e2\">\u524d\u56de<\/a>\u306e touchesBegan \u30e1\u30bd\u30c3\u30c9\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u308b\u3002<\/p>\n<pre class=\"brush: objc; title: ; notranslate\" title=\"\">-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {\r\n    \/* Called when a touch begins *\/\r\n     \r\n    for (UITouch *touch in touches) {\r\n        CGPoint location = &#x5B;touch locationInNode:self];\r\n         \r\n        SKSpriteNode *sprite = &#x5B;SKSpriteNode spriteNodeWithImageNamed:@&quot;Ball&quot;];\r\n         \r\n        sprite.position = location;\r\n         \r\n        const CGFloat radius = 20.0f;\r\n        SKPhysicsBody *pbody = &#x5B;SKPhysicsBody bodyWithCircleOfRadius:radius];\r\n        pbody.contactTestBitMask = 1;\r\n        sprite.physicsBody = pbody;\r\n        sprite.size = (CGSize){radius * 2, radius * 2};\r\n         \r\n        &#x5B;self addChild:sprite];\r\n    }\r\n}<\/pre>\n<p>pbody.contactTestBitMask = 1; \u306e\u884c\u3092\u8ffd\u52a0\u3057\u305f\u3060\u3051\u3067\u3042\u308b\u3002<br \/>\n\u3053\u308c\u3067 didBeginContact \u30e1\u30bd\u30c3\u30c9\u304c\u547c\u3070\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u3001\u885d\u7a81\u70b9\u304b\u3089\u706b\u82b1\u304c\u6563\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u306f\u305a\u3067\u3042\u308b\u3002<\/p>\n<p>\u306a\u305c\u3053\u308c\u3060\u3051\u3067\u826f\u3044\u306e\u304b\u3092\u77e5\u308b\u305f\u3081\u306b\u306b\u306f\u3001\u3082\u3046\u3072\u3068\u3064\u306e\u30d3\u30c3\u30c8\u30de\u30b9\u30af\u3067\u3042\u308b categoryBitMask \u306b\u3064\u3044\u3066\u77e5\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<br \/>\ncategoryBitMask \u306f\u305d\u306e\u525b\u4f53\u304c\u3069\u306e\u30ab\u30c6\u30b4\u30ea\u306b\u5c5e\u3059\u308b\u304b\u3092\u8868\u3059\u30d3\u30c3\u30c8\u5024\u3067\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306f0xffffffff\u3067\u3042\u308b\u3002<\/p>\n<p>SKPhysicsWorld \u306e\u5185\u90e8\u3067\u306f\u3001\u525b\u4f53\u540c\u58eb\u304c\u3076\u3064\u304b\u3063\u305f\u5834\u5408\u306b\u3001\u7247\u65b9\u306e\u525b\u4f53\u306e contactTestBitMask \u3068\u3082\u3046\u7247\u65b9\u306e categoryBitMask \u3067\u8ad6\u7406\u7a4d\uff08AND\uff09\u3092\u3068\u308a\u3001\u305d\u306e\u7d50\u679c\u304c0\u3067\u306a\u3051\u308c\u3070  SKPhysicsContact \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u751f\u6210\u3057\u3001\u30c7\u30ea\u30b2\u30fc\u30c8\u306e didBeginContact \u30e1\u30bd\u30c3\u30c9\u306a\u3069\u304c\u547c\u3070\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3002<br \/>\ncontactTestBitMask \u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306f0x00000000\u306a\u306e\u3067\u3001\u305d\u306e\u307e\u307e\u3060\u3068 didBeginContact \u30e1\u30bd\u30c3\u30c9\u306a\u3069\u304c\u3088\u3070\u308c\u308b\u4e8b\u306f\u4e00\u5207\u7121\u3044\u3002<br \/>\n\u624b\u8efd\u3055\u3092\u5fd7\u5411\u3057\u3066\u3044\u308bSpriteKit\u306b\u304a\u3044\u3066\u306f\u3001\u73cd\u3057\u304f\u9762\u5012\u306a\u4ed5\u69d8\u3060\u304c\u3001\u885d\u7a81\u5224\u5b9a\u304b\u3089\u885d\u7a81\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u751f\u6210\u3001\u30c7\u30ea\u30b2\u30fc\u30c8\u30e1\u30bd\u30c3\u30c9\u547c\u3073\u51fa\u3057\u306e\u4e00\u9023\u306e\u51e6\u7406\u304c\u6bd4\u8f03\u7684\u91cd\u3044\u306e\u3067\u3053\u3046\u3044\u3046\u4ed5\u69d8\u306b\u306a\u3063\u3066\u3044\u308b\u3088\u3046\u3067\u3042\u308b\u3002<\/p>\n<p>contactTestBitMask \u306f\u305d\u306e\u540d\u306e\u3068\u304a\u308a\u30d3\u30c3\u30c8\u30de\u30b9\u30af\u306a\u306e\u3067\u3001\u4f8b\u3048\u3070\u525b\u4f53A\uff08\u6575A\uff09\u3068\u525b\u4f53B\uff08\u6575B\uff09\u540c\u58eb\u306b\u95a2\u3057\u3066\u306f\u7279\u5225\u306a\u885d\u7a81\u6642\u306e\u51e6\u7406\u306f\u5fc5\u8981\u306a\u3044\u304c\u3001\u525b\u4f53C\uff08\u30d7\u30ec\u30a4\u30e4\u30fc\uff09\u3068\u525b\u4f53A\u3082\u3057\u304f\u306f\u525b\u4f53B\u306e\u885d\u7a81\u6642\u306b\u306f\u7279\u5225\u306a\u51e6\u7406\u3092\u884c\u3044\u305f\u3044\u3068\u3044\u3046\u3088\u3046\u306a\u5834\u5408\u306b\u3082\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8a2d\u5b9a\u306b\u3059\u308c\u3070\u5bfe\u5fdc\u51fa\u6765\u308b\u3002<\/p>\n<pre class=\"brush: objc; title: ; notranslate\" title=\"\">player.categoryBitMask = 1;\r\nenemyA.categoryBitMask = 2;\r\nenemyB.categoryBitMask = 2;\r\n\r\nplayer.contactTestBitMask = 2;\r\nenemyA.contactTestBitMask = 1;\r\nenemyA.contactTestBitMask = 1;<\/pre>\n<p>\u5b9f\u306f\u3001 SKPhysicsBody \u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306b BitMask \u3068\u4ed8\u304f\u3082\u306e\u304c\u3082\u3046\u3072\u3068\u3064\u3042\u308b\u3002<br \/>\ncollisionBitMask \u3067\u3042\u308b\u3002<\/p>\n<p>collisionBitMask \u306f\u3069\u306e\u30ab\u30c6\u30b4\u30ea\u306e\u525b\u4f53\u3068\u885d\u7a81\u3059\u308b\u304b\u3092\u6307\u5b9a\u3059\u308b\u305f\u3081\u306e\u30d3\u30c3\u30c8\u30de\u30b9\u30af\u3067\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306f0xffffffff\u3068\u306a\u3063\u3066\u3044\u308b\u3002<br \/>\n2\u3064\u306e\u525b\u4f53\u306e collisionBitMask \u3068 categoryBitMask \u3067\u8ad6\u7406\u7a4d\u3092\u3068\u3063\u305f\u7d50\u679c\u304c0\u306b\u306a\u308b\u3068\u305d\u306e\u525b\u4f53\u540c\u58eb\u306f\u3059\u308a\u629c\u3051\u308b\u3002<\/p>\n<h3>\u304a\u308f\u308a\u306b<\/h3>\n<p>SpriteKit\u306e\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u7c21\u5358\u306a\u30a2\u30d7\u30ea\u3092\u4f5c\u308a\u306a\u304c\u3089\u898b\u3066\u304d\u305f\u304c\u3001\u975e\u5e38\u306b\u7c21\u5358\u306b\u4f7f\u3048\u308b\u4e8b\u304c\u5206\u304b\u3063\u305f\u3068\u601d\u3046\u3002<br \/>\n\u3057\u304b\u3057\u307e\u3060\u30b5\u30a6\u30f3\u30c9\u95a2\u9023\u3084\u30a2\u30af\u30b7\u30e7\u30f3\u95a2\u9023\u3001\u3042\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5468\u308a\u306f\u5168\u7136\u898b\u3066\u3044\u306a\u3044\u3002<br \/>\n\u305d\u306e\u8fba\u308a\u3082\u8abf\u3079\u305f\u3089\u8a18\u4e8b\u3092\u66f8\u304f\u304b\u3082\u3057\u308c\u306a\u3044\u304c\u3001\u591a\u5206\u4eca\u56de\u306e\u3088\u3046\u306b\u3061\u3083\u3093\u3068\u306f\u66f8\u304b\u306a\u3044\u3060\u308d\u3046\uff08\u75b2\u308c\u308b\u306e\u3067w\uff09\u3002<\/p>\n<p>SpriteKit\u3067\u3001\u30b2\u30fc\u30e0\u4f5c\u6210\u8005\u4eba\u53e3\u304c\u5897\u3048\u308b\u3068\u3044\u3044\u306a\u3041(*\u00b4\u2200\uff40*)\uff8e\uff9f\uff9c\uff9c<\/p>\n","protected":false},"author":1,"featured_media":3119,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[473,413,156,468],"class_list":["post-3112","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech","tag-featured","tag-ios","tag-objective-c","tag-spritekit"],"_links":{"self":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts\/3112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/comments?post=3112"}],"version-history":[{"count":0,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts\/3112\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/media\/3119"}],"wp:attachment":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/media?parent=3112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/categories?post=3112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/tags?post=3112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}