我有一個繪圖應用程序,我希望我的用戶能夠使用粒子效果作爲其繪圖的一部分。基本上,應用程序的重點是執行自定義繪圖並保存到相機膠捲或共享通過萬維網。當超級層的-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