Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6604087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:06:23+00:00 2026-05-25T19:06:23+00:00

hey i am running into a problem. i maade an image object that gets

  • 0

hey i am running into a problem.
i maade an image object that gets added every 2 seconds by an nstimer.
and an update timer updates it so the image goes forward.
but it only goes forward until a new one gets added and i can’t solve why.

this is the method for adding it.

-(void)addTarget {

UIImage *image1=[UIImage imageNamed:@"enemy.png"];
                 image=[[UIImageView alloc]initWithImage:image1];
                 image.frame=CGRectMake(0,0,50,50);
                 [self.view addSubview:image];
image.center = CGPointMake(150, 150);
image.tag = 1;
[_targets addObject:image];
                     [image release];       
}

self explaining.

-(void) update {
 image.center = CGPointMake(image.center.x+2, image.center.y);

}

and this spawns them.

-(void) spawn {
[self addTarget];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:06:24+00:00Added an answer on May 25, 2026 at 7:06 pm

    Its because you are constantly reallocating the image. You need to be creating a new image1 variable every time and then adding it to an NSMutableArray.

    Then in the update method use a for loop to move each image in the array’s centre to whatever point.

    - (void)update {
        for (UIImage *image in _targets) {
            image.center = CGPointMake(image.center.x+2, image.center.y);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey guys m running into a problem, i have a forloop n in that
Hey php gurus. I'm running into some bizarre class scope problems that clearly have
Hey guys I'm running into a weird issue.. Basically, a user logs into a
Hey everyone, running into a bit of an issue, I have created all my
Hey all, I'm running into an error using form_tag in Rails 2.3 and can't
Hey there! I'm trying to serialize data in AS3 but am running into a
Hey. Been running into a rash of problems trying to make projects version controlled.
Hey everybody, I am writing a program that compares the running times of various
Hey I got problem in running .NET framework 4.0 website on IIS7.0 . the
Hey guys, i have a crazy problem. I have been running my webapp on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.