Apple のドキュメントは、このクラス メソッドを効果的に実装する方法の説明に関してはあいまいです。
+ (SKPhysicsBody *)bodyWithBodies:(NSArray *)bodies; //the error that I'm getting is 2014-04-23 23:25:21.518 Space Monkey[3398:60b] -[SKSpriteNode _shapes]: unrecognized selector sent to instance 0x15d79c50
2014-04-23 23:25:21.520 Space Monkey[3398:60b] * キャッチされない例外 'NSInvalidArgumentException' が原因でアプリを終了します。 (0x2d92ef03 0x380c3ce7 0x2d932837 0x2d93112f... 例外がスローされており、運が悪くてどこでもかなり調査しました。同じ問題について別の質問がありますが、提案はまったく機能していないようです。誰かが光を当てて、うまくいけば私を正しい方向に向けるためにコードを提供しました...これがコードです
-(NSMutableArray *)platformBars
{
NSMutableArray *array =[[NSMutableArray alloc]init];
//_spriteNode declared in the interface as an instance variable
_spriteNode=[SKSpriteNode node];
for (int i =0; i<5; i++)
{
_spriteNode= [SKSpriteNode spriteNodeWithImageNamed:@"Water Block"];
_spriteNode.physicsBody.mass = 10.0f;
_spriteNode.physicsBody.density = _spriteNode.size.height;
_spriteNode.position = CGPointMake(x , _spriteNode.position.y);
x=x+40;
[array addObject:_spriteNode];
}
return array;
}
-(PlatformNode *)createPlatformsAtPosition:(CGPoint)position
{
NSArray *arrays = [self platformBars];
PlatformNode *node =[PlatformNode node];
node.physicsBody = [SKPhysicsBody bodyWithBodies:arrays];
for (SKSpriteNode *sknode in arrays)
{
[node addChild:sknode];
}
node.position=position;
node.name =@"platform";
node.physicsBody.affectedByGravity = NO;
NSLog(@"bodyofSize %f",[node calculateAccumulatedFrame].size.width);
return node;
}
-(PlatformNode *)createPlatformsAtPosition:(CGPoint)position is called in the
-(void)didMoveToView:(SKView *)view body of the function.
十分な詳細とコードのスニペットが含まれていることを願っているので、誰かが私や他の人も同様に来るのを助けてくれることを願っています. 前もって感謝します。