Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何制作弹跳球应用程序_Iphone_Ios4 - Fatal编程技术网

Iphone 如何制作弹跳球应用程序

Iphone 如何制作弹跳球应用程序,iphone,ios4,Iphone,Ios4,我一直在按照教程制作弹跳球应用程序。 但是我想做的是做20-30个球,可以在iphone屏幕上的任何地方通过用户触摸拖动,也可以在屏幕上的任何地方掉落。因此,有人能给我一些建议吗?如何在不使用cocos2d的iphone中做到这一点,请帮我解决问题,或者给我一些链接或有用的信息。任何帮助都将不胜感激。…在上述代码中工作时,您可以编写touchesMoved方法来处理ballView的位置 试试这个 还是这个更新的 - (void) touchesMoved:(NSSet *)touches wi

我一直在按照教程制作弹跳球应用程序。
但是我想做的是做20-30个球,可以在iphone屏幕上的任何地方通过用户触摸拖动,也可以在屏幕上的任何地方掉落。因此,有人能给我一些建议吗?如何在不使用cocos2d的iphone中做到这一点,请帮我解决问题,或者给我一些链接或有用的信息。任何帮助都将不胜感激。…

在上述代码中工作时,您可以编写touchesMoved方法来处理ballView的位置

试试这个

还是这个更新的

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{


    if ([touches count] == 1) {
        UITouch *newTouch = [[touches anyObject] locationInView:[self superview]]; 
        UITouch *lastTouch = [[touches anyObject] previousLocationInView: [self superview]];
        NSLog(@"xxxxxggdfgdfgfdgdfg%f",newTouch.x);
        NSLog(@"yyyyyyggdfgdfgfdgdfg%f",newTouch.y);
        xDif = newTouch.x - lastTouch.x; 
        yDif = newTouch.y - lastTouch.y;


        }
        CGAffineTransform translate = CGAffineTransformMakeTranslation(xDif, yDif);
        [self setTransform: CGAffineTransformConcat([self transform], translate)]; 
    } 
你可以使用定时器{

pos=CGPointMake7.0,14.0; 计时器=[NSTimer scheduledTimerWithTimeInterval:0.05目标:自选择器:@selectoronTimer userInfo:nil repeats:YES]; }

并使用选择器调用该方法

-无效时间{ image.center=CGPointMakeimage.center.x+pos.x,image.center.y+pos.y;
如果image.center.x>320 | | | image.center.xhey,谢谢vijay,但我已经使用Ntimer完成了,我的应用程序也在运行,但我希望它可以用于20-30个球。用户应该能够触摸每个球,用户还应该能够拖动每个球和每个球的30个球,也可以放下其中的30个球,所以有什么帮助吗?谢谢ravin的帮助,但代码是这样的u建议不起作用,它拖动我的整个视图而不是球。我想做的是在使用drawrect方法制作球后,每个球都应该在用户触摸时独立拖放。在BallView类中编写此方法…继承UIImageView。不在任何其他视图中…这只会移动球的位置。另外,不要伪造t写入[self-setUserInteractionEnabled:是]在BallView的init方法中。嘿,ravin,我尝试了你的两种方法,但都不起作用。如果我将上面的转换方法放在一个方法中,那么这将不允许根viewcontroller的TouchsMoved方法调用,因此我将无法拖动和丢弃任何球,所以,尽管如此,谢谢budywhere将此方法放在哪个类中?
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{


    if ([touches count] == 1) {
        UITouch *newTouch = [[touches anyObject] locationInView:[self superview]]; 
        UITouch *lastTouch = [[touches anyObject] previousLocationInView: [self superview]];
        NSLog(@"xxxxxggdfgdfgfdgdfg%f",newTouch.x);
        NSLog(@"yyyyyyggdfgdfgfdgdfg%f",newTouch.y);
        xDif = newTouch.x - lastTouch.x; 
        yDif = newTouch.y - lastTouch.y;


        }
        CGAffineTransform translate = CGAffineTransformMakeTranslation(xDif, yDif);
        [self setTransform: CGAffineTransformConcat([self transform], translate)]; 
    } 
    if (image.center.y>460 || image.center <0 ) 
    pos.y=-pos.y;