0

I placed the object in middle of the screen and move the object from left to right.(10 objects). If touched the objects and i make as invisible (setHidden) but still object will moving and collided at end of object . What method will use for object make invisible and stop the object at the same position.

I used the following method 1.setHidden 2. removeFromSuperview

But still is not working. Plz help

Sample code:

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    for(int i = 0; i < no_images; i++)
    {
        img_arrows = [arr_Container objectAtIndex:i];

        UITouch *touch = [[event allTouches]anyObject];

        if([touch view]== img_arrows)
        {
            tag2 = [img_arrows tag];
            //  printf("tag in touch method----->>>>%d\n",tag2);

            switch(tag2)
            {
                case 0:
                    if(y_axis[i] >=190 && y_axis[i] <=214)
                    {
                        if(x_start_arrows > x_end)
                        {   
                            [img_good setHidden:NO];                    
                            [img_arrows setHidden:YES];

                        }
                    }
            }
        }
}
Luke
  • 11,426
  • 43
  • 60
  • 69
JohnRaja
  • 2,377
  • 6
  • 26
  • 47

2 Answers2

3

This answer explains that a moving button doesn't actually move until the animation is done. You'll need to use Quartz 2D, or an NSTimer to move your buttons if you want them to animate and perfectly respond to touches. See this question for more details.

Community
  • 1
  • 1
Moshe
  • 57,511
  • 78
  • 272
  • 425
0

Instead of using setHidden you could use setAlpha to show/hide the img_good and img_arrows.

werner
  • 859
  • 4
  • 8