我希望在cocos2d游戏中添加放大镜效果。这是我在线上找到的内容:
http://coffeeshopped.com/2010/03/a-simpler-magnifying-glass-loupe-view-for-the-iphone
我稍微更改了一下代码:(因为我不想让放大镜跟随我们的触摸)
我希望您能将其添加到我的场景初始化方法之一中。
但结果是:放大镜内部的区域是黑色的。此外,这个放大镜只能以相同的比例放大图像,如何调整它使得中心区域放大更多,边缘区域放大更少?(就像真正的放大镜一样)谢谢!
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:magnifier_rect])) {
// make the circle-shape outline with a nice border.
self.layer.borderColor = [[UIColor lightGrayColor] CGColor];
self.layer.borderWidth = 3;
self.layer.cornerRadius = 250;
self.layer.masksToBounds = YES;
touchPoint = CGPointMake(CGRectGetMidX(magnifier_rect), CGRectGetMidY(magnifier_rect));
}
return self;
}
我希望您能将其添加到我的场景初始化方法之一中。
loop = [[MagnifierView alloc] init];
[loop setNeedsDisplay];
loop.viewToMagnify = [CCDirector sharedDirector].openGLView;
[[CCDirector sharedDirector].openGLView.superview addSubview:loop];
但结果是:放大镜内部的区域是黑色的。此外,这个放大镜只能以相同的比例放大图像,如何调整它使得中心区域放大更多,边缘区域放大更少?(就像真正的放大镜一样)谢谢!