1
如何將鏡頭效果應用於我的UIImage,如圖所示http://processing.org/learning/topics/lens.html?如何將鏡頭效果應用於我的UIImage?
如何將鏡頭效果應用於我的UIImage,如圖所示http://processing.org/learning/topics/lens.html?如何將鏡頭效果應用於我的UIImage?
您可以使用Cocos2D框架來做到這一點。
如果您選擇使用它,這裏是你如何可以輕鬆地應用透鏡效應:
- (void)aFunction
{
const CGSize size = [[CCDirector sharedDirector] winSize];
// Init and position your image
CCSprite *img = [CCSprite spriteWithFile:@"images.png"];
img.position = ccp(size.width/2.f, size.height/2.f);
[self addChild:img];
// Create action and start it
id lens = [CCLens3D actionWithPosition:ccp(size.width/2.f, size.height/2.f)
radius:240.f
grid:ccg(15.f,10.f)
duration:0.f];
[img runAction:lens];
}
你的項目很可能是這樣,你不想重新從頭開始你的項目的UIKit項目。所以,在cocos2d-ios Xcode項目中有很多你可以做的事例。
還有一個叫做AttachTest的例子,它展示瞭如何在UIKit項目中實現一個EAGLView(它是UIView的子類)。
謝謝,但我想從零開始做這個效果。你能給我提供一些代碼或算法嗎? – dpart 2011-05-25 18:10:24
@dpart你應該看看Cocos2D是如何做到的。它是基於OpenGL框架的,我想你可以從它那裏拿一些代碼給你...... – klefevre 2011-05-26 08:30:17