我有一个绘图应用程序,我希望我的用户能够使用粒子效果作为其绘图的一部分。基本上,应用程序的重点是执行自定义绘图并保存到相机胶卷或共享通过万维网。当超级层的-renderInContext被调用时,CAEmitterLayer不渲染
我最近上了CAEmitterLayer
这个课,我认为这是一种简单而有效的添加粒子效果的方法。
我已经能够在应用程序中使用CAEmitterLayer
实现在屏幕上绘制粒子。所以在屏幕上渲染效果很好。
当我去使用
CGContextRef context = UIGraphicsBeginImageContextWithSize(self.bounds.size);
// The instance drawingView has a CAEmitterLayer instance in its layer/view hierarchy
[drawingView.layer renderInContext:context];
//Note: I have also tried using the layer.presentationLayer and still nada
....
//Get the image from the current image context here for saving to Camera Roll or sharing
....the particles are never rendered in the image.
我觉得渲染图形的内容正在发生
的CAEmitterLayer
在“动画”粒子的恒定状态。这就是为什么当我尝试渲染图层时(我也尝试渲染layers.presentationLayer
和modelLayer),动画永远不会被提交,因此脱离屏幕图像渲染不包含粒子。
问题 有没有人在屏幕外呈现CAEmitterLayer
的内容?如果是这样,你是怎么做到的?
替代问题 有谁知道,请不要使用OpenGL和没有任何的cocos2d粒子特效系统库的?
这样的运气呢? – 2012-09-26 17:04:24
不,请参阅下面的Revis答案。 CAEmitterLayer无法调用renderInContext: – micksabox 2013-03-05 16:05:48