I'm相当新的编程,我已经有点半做了我的(简单)的应用程序,但我想知道如何绘制的图片在屏幕上(用户绘制的图片)和然后使用该图片的游戏,只是向左和向右移动(并检查其是否与其它图像碰撞)。借鉴了iPhone的目标C
我有这个..
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];
}
但后来当我按下一个蓝色方形转到手指在屏幕上,但会费不画任何东西......
所以你想画一个用户通过屏幕移动手指时的图片? – booleanBoy
是啊........... – miniman