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