尝试使用Xcode 6制作自定义形状

时间:2014-06-11 14:49:41

标签: ios objective-c xcode sprite-kit

想要制作具有适合其质地的形状的物理身体。 我这样做是像在wwdc视频中解释的那样,但我得到了这个例外:

    2014-06-11 16:42:05.673 jumps[536:60b] +[SKPhysicsBody bodyWithTexture:size:]: unrecognized selector sent to class 0x39b017b4
2014-06-11 16:42:05.681 jumps[536:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[SKPhysicsBody bodyWithTexture:size:]: unrecognized selector sent to class 0x39b017b4'

这样做:

SKTexture *temp = _heroWalkingFrames[0]; //textures loaded from a .atlas folder
    SKSpriteNode *hero = [SKSpriteNode spriteNodeWithTexture:temp];

    hero.name = @"hero";
    hero.zPosition = 1;
    [hero setPosition:CGPointMake(100, 220)];
    [hero setSize:CGSizeMake(25, 25)];

    //here I set the physicBody with the old way and still works: hero.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:CGSizeMake(23, 25)];

//this is the new way of doing but it throw exceptions :(
      hero.physicsBody = [SKPhysicsBody bodyWithTexture:temp size:hero.size];

//or 
    //hero.physicsBody = [SKPhysicsBody bodyWithTexture:temp alphaThreshold:0.1 size:hero.size];

我用x-code 6做这个并在iphone 4中构建它... 有谁知道我做错了什么?

0 个答案:

没有答案