0

When I am editing a sks scene in the Xcode editor and I highlight a SKSpriteNode there are the fields "Custom Class" and "Module".

enter image description here

How can I use these fields if a have implemented a Subclass of SKSpritenode?

It does not work if I fill in the class name, for example

Custom Class: "MyCustomBomb"

@interface MyCustomBomb : SKSpriteNode

EDIT:

@implementation MyCustomBomb

-(id)init{
    if (self = [super init]) {
        SKSpriteNode *image = [SKSpriteNode spriteNodeWithImageNamed:@"image"];
        [self addChild:image];

        textlabel = [SKLabelNode labelNodeWithText@"test text"];
        [self addChild:textlabel];
    }
    return self;
}
Talumux
  • 68
  • 1
  • 8
  • What doesn't work? How are you looking for success? – stevesliva Sep 20 '15 at 18:17
  • For example custom behavior does not work, if the implementation is similar to the example i added above, I do not see the additional sprites and labels. – Talumux Sep 21 '15 at 15:32
  • 1
    Doesn't appear that `init` is [the designated initializer for SKSpriteNode](http://stackoverflow.com/questions/25164313/swift-must-call-a-designated-initializer-of-the-superclass-skspritenode-error) – stevesliva Sep 21 '15 at 19:17
  • very good advise. Now I call the designated initializer: self = [self initWithTexture:textue color:color size:size]; but it still does not work :( – Talumux Sep 23 '15 at 19:59
  • Typo? `self = [super initWith...` not `self = [self`... – stevesliva Sep 23 '15 at 20:15
  • yes, definitely a typo :S But it does not work anyhow... – Talumux Sep 23 '15 at 21:14
  • Oh, but in terms the subclass, it must override the designated initializer of the super. `init` still won't ever get called... I was assuming you'd fixed the method prototype as well. – stevesliva Sep 23 '15 at 23:26
  • mh, it seems my understanding and my programming skills aren't the best^^ Maybe some has a short example code snippet or a link to a tutorial? I'm stuck now :( – Talumux Sep 26 '15 at 10:46

0 Answers0