如何在点击xcode上增加某些内容

时间:2012-06-17 10:10:31

标签: iphone ios xcode

我在重载器中有两组vaules,希望每次IBAction开始执行时都会增加

这是我的例子

- (void)viewDidLoad
{
    [super view];
    //X Speed and Y Speed
    pos = CGPointMake(2,1);
    pos2 = CGPointMake(2,1);

}


- (IBAction)start 
{

)

我不会将int分配到2,1等,但pos和pos2值将是不同的

1 个答案:

答案 0 :(得分:1)

只需在调用start方法时递增x和y值。

- (void)viewDidLoad
{
    [super view];
    //X Speed and Y Speed
    pos = CGPointMake(2,1);
    pos2 = CGPointMake(2,1);

}


- (IBAction)start 
{
   //So you just increment their x and y values
   pos.x += 1;
   pos.y += 1;

   pos2.x += 2;
   pos2.y += 1;
}