gpt4 book ai didi

iphone - 在 objective-c 中绘制 iPhone

转载 作者:搜寻专家 更新时间:2023-10-30 20:11:24 25 4
gpt4 key购买 nike

<分区>

我对编程很陌生,我的(简单)应用程序已经制作了一半,但我想知道如何在屏幕上绘制图片(用户绘制图片),然后将该图像用于游戏只是左右移动(并检查它是否与另一张图片发生碰撞)。

我知道了..

float pointx;
float pointy;


- (void)drawRect:(CGRect)rect {
CGColorRef blue = [[UIColor blueColor] CGColor];

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClearRect(context, self.bounds);

CGContextSetFillColorWithColor(context, blue);
CGContextFillRect(context, CGRectMake(pointx, pointy, 10, 10));

}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch=[[event allTouches]anyObject];
CGPoint point = [touch locationInView:touch.view];
pointx = point.x;
pointy = point.y;
[self setNeedsDisplay];
}

但是当我在屏幕上按下时,一个蓝色方 block 会出现在手指上,但不会绘制任何东西...

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com