ios开发里,想用定时器实现一个小球碰撞 30
,主界面的代码如下_imageview=[[UIImageViewalloc]initWithFrame:CGRectMake(50,50,50,50)];_imagev...
,主界面的代码如下
_imageview = [[UIImageView alloc]initWithFrame:CGRectMake(50, 50, 50, 50)];
_imageview.tag = 1;
_imageview.image = [UIImage imageNamed:@"11"];
[self.window addSubview:_imageview];
_timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(tantan:) userInfo:nil repeats:YES];
在定时器调用的方法里面,具体应该怎么写呢,我写不出来,求大神赐教
-(void)tantan:(NSTimer *)timer
{
_imageview.center = CGPointMake(_imageview.center.x + 3, _imageview.center.y + 3);
走到最右边就不会写了 展开
_imageview = [[UIImageView alloc]initWithFrame:CGRectMake(50, 50, 50, 50)];
_imageview.tag = 1;
_imageview.image = [UIImage imageNamed:@"11"];
[self.window addSubview:_imageview];
_timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(tantan:) userInfo:nil repeats:YES];
在定时器调用的方法里面,具体应该怎么写呢,我写不出来,求大神赐教
-(void)tantan:(NSTimer *)timer
{
_imageview.center = CGPointMake(_imageview.center.x + 3, _imageview.center.y + 3);
走到最右边就不会写了 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询