خرید بک لینک

Vote count: 0

It seems to me that I imported the correct files properly. When I want to initialize a sprite object I get an error that there is no selector 'hero', when I clearly defined it in MLHero.h.

GameScene.m:

#import "GameScene.h"

@implementation GameScene

-(void)didMoveToView:(SKView *)view {
    /* Setup your scene here */

    self.anchorPoint = CGPointMake(0.5, 0.5);
    self.backgroundColor = [SKColor colorWithRed:0.30 green:0.2 blue:0.15 alpha:1.0];

    SKSpriteNode *ground = [SKSpriteNode spriteNodeWithColor:[UIColor greenColor] size:CGSizeMake(self.frame.size.width, 60)];
    ground.position = CGPointMake(0, -self.frame.size.height/2 + ground.frame.size.height/2);
    ground.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:ground.size];
    ground.physicsBody.dynamic = NO;


    // > ERROR HAPPENS HERE: No known class method for selector 'hero'
    MLHero *hopHero = [MLHero hero];


    [self addChild:hopHero];
    [self addChild:ground];

}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    /* Called when a touch begins */


}

-(void)update:(CFTimeInterval)currentTime {
    /* Called before each frame is rendered */
}

@end

MLHero.m:

#import "MLHero.h"

@implementation MLHero

+(instancetype)hero
{
    MLHero *hero = [self spriteNodeWithColor:[UIColor whiteColor] size:CGSizeMake(40,40)];
    hero.name = @"hero";
    hero.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:hero.size];

    retu hero;
}

@end

MLHero.h:

#import <SpriteKit/SpriteKit.h>

@interface MLHero : SKSpriteNode

+(instancetype)hero;

@end

asked 3 mins ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 24 خرداد 1395 ساعت: 3:40

صفحه بندی