0
我需要显示一个gif图像,我试过SKSpriteNote
但它没有gif支持。所以我想用UIImageView
代替。无法将UIImageView放入SKScene的视图
在MyScene.m init方法:
#import "UIImage+animatedGIF.h"
CGSize size = CGSizeMake(144, 82);
//create a uiview on top of skview
self.demoView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width/2 - size.width/2, self.view.bounds.size.height/2 - size.height/2, size.width, size.height)];
[self.view addSubview:self.demoView];
//set the image to be the gif (I use a category from github)
self.demoView.image = [UIImage animatedImageWithAnimatedGIFURL:[NSURL URLWithString:[Helper pathInBundleWithFileName:[self demoFileNameWithStep:step]]]];
[self.demoView startAnimating];
这不是GIF图像,因为即使我尝试静态的png图片,不显示的图像视图。
我已经试过这是很好,但它不工作之一:是指self.view
到SKScene方法didMoveToView:
[self.view.superview addSubview:self.demoView];
[self.view.superview bringSubviewToFront:self.demoView];
屏幕外的图像帧或许? – LearnCocos2D
图像应该是在skview的中心。我没有看到任何错误计算 – OMGPOP
检查self.view是非零。如果这个代码在init中,它将是零。 – LearnCocos2D