Open zeitweise opened 10 years ago
Good catch! I implemented your fix in my fork of this project.
https://github.com/mredig/SKUtilities (I haven't merged the working branch into the master branch quite yet, so this is included in the working branch as of this post)
Basically the same as what @mredig said: Thanks, and I've merged this into my fork! My fork contains only DSMultilineLabelNode
, if that's useful. Here it is: https://github.com/karlvoskuil/DSMultilineLabelNode
Hi,
thanks a lot for your code snippet.
I found an issue in retexture. When self.text is nil or @"" newTextImage gets nil. That is a problem because if you try to call [SKTexture textureWithImage:nil] you will get a crash. That's why I safeguarded the call and filled in a nil texture in selfNode.texture = newTexture; if there is no newTextImage.
Best regards Marcel-André
-(void)retexture { DSMultiLineLabelImage *newTextImage = [self imageFromText:self.text];
SKTexture *newTexture; if (newTextImage) { newTexture =[SKTexture textureWithImage:newTextImage]; }
SKSpriteNode selfNode = (SKSpriteNode) self;
selfNode.texture = newTexture;
//Resetting the texture also reset the anchorPoint. Let's recenter it. selfNode.anchorPoint = CGPointMake(0.5, 0.5); }