How to make 2 balls move at the same time

I am working on an app in xcode and I need to make 2 balls move at the same time. When I try to use the same code for both of the balls, the 2 CGPoints interfere. Here is my code in the .m file.
@synthesize ball, ball2;
-(void) onTimer {
        ball.center = CGPointMake(ball.center.x+pos.x,ball.center.y+pos.y);
        if(ball.center.x > 295 || ball.center.x < 10)
            pos.x = -pos.x;
        if(ball.center.y > 435 || ball.center.y < 35)
            pos.y = -pos.y;
- (void) onTimer2 {
ball2.center = CGPointMake(ball2.center.x+pos.x,ball2.center.y+pos.y);
if(ball2.center.x > 295 || ball2.center.x < 10)
pos.x = -pos.x;
if(ball2.center.y > 435 || ball2.center.y < 35)
pos.y = -pos.y;
[self collision];
- (void)viewDidLoad
          [[NSTimer scheduledTimerWithTimeInterval:0.04 target:self selector:@selector(onTimer) userInfo:nil repeats:YES] retain];
    [[NSTimer scheduledTimerWithTimeInterval:0.04 target:self selector:@selector(onTimer2) userInfo:nil repeats:YES] retain];
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
Here is my .h file
@interface game : UIViewController {
    IBOutlet UIImageView *ball;
    IBOutlet UIImageView *ball2;
@property(nonatomic,retain) IBOutlet UIImageView *ball;
@property(nonatomic,retain) IBOutlet UIImageView *ball2;

What do you mean by the 2 CGPoints interfere?
You're changing the location of the balls by pos.x and pos.y, where is the code for those? what is it doing?
Why have two timers?  One timer would work , just have the code move both balls.
The refresh rate for the screen is 60hz. (60 time a second) You'll get better animation if you stick as close to this value as you can.

Similar Messages

  • How do I get 2 layers to move at the same time?

    How do you get 2 layers to move at the same time?

    Thanks for the help folks, sorry I've been away.
    I'd love help with the problem of why I only one track seems to accept clips to play. When I drag them to other tracks or create a track by dragging the clips are grayed out and won't play, but if I drag them to the one track where they're blue they play.

  • How can i hide phone apps so that if kids take my mobile the couldnt be able to make calls. At the same time when someone call me I could be able to attend call. is there any control to lock phone's apps or hide it.

    how can i hide phone apps so that if kids take my mobile the couldnt be able to make calls. At the same time when someone call me I could be able to attend call. is there any control to lock phone's apps or hide it.

    Hi there
    Apple doesnt give this feauture and there are certain apps in app store under utilities which provide password facility under this app and u can store photos videos and orther stuff and lock so
    Kids will be not able to access this single app ortherwise there is no such feature of locking apps feature given by apple
    <Edited By Host>

  • HT1657 Can you rent more than one movie at the same time?

    Can you rent more than one movie at the same time on itunes?

    I think Justin is correct and you should have statistics in place and a reasonable partition scheme so that the optimizer selects the correct partitions rather than telling it what to do. You paid a lot for partitioning after all.
    There are some, possibly misguided, examples in the manuals showing how to create a view so you can delete from a single partition without specifying the partition criteria in the delete statement. This in effect turns partitioning back into DIY partitioning i.e. separate tables, union all and pretend its a single logical table using a view. But backwards.
    So to do what you want you just assume the partitions are separate tables, and then use union all to glue the ones you want back together.
    select * from sales partition (sales_q1_2000)
    union all
    select * from sales partition (sales_q1_2001)
    union all
    select * from sales partition (sales_q1_2003)
    union all
    select * from sales partition (sales_q1_2004);It probably goes without saying that as well as making the expensive version of partitioning behave like the free alternative, there is the possibility that it will perform like it as well.

  • Stream from iMac to 2 different ATV's; different movies, at the same time?

    Can I stream  from my iTunes library on my mid 2014 iMac; to two different 3rd gen ATV's, two different movies at the same time?

    Thank you Alley_Cat for your reply!
    Yes...all devices are enabled for Home Sharing with the same APPLE ID, all on the same network, the content is in iTunes and compatible, computer and iTunes running, and I am initiating playback on the AppleTVs themselves via the Computers icon.
    playback is is fine on 1st ATV. When I TRY to connect to ATV #2... and try to connect to my iTunes library i get:
    COULD NOT CONNECT TO _______ LIBRARY MAKE SURE COMPUTER IS ON THE SAME NETWORK AND ITUNES IS UP TO DATE AND ITUNES IS RUNNING.
    iTunes is up to date ver11.3.1.(2) .  As noted before,same network iTunes compatible, running and initiating playback on ATV's via Computers icon.

  • Working on 5 movies at the same time and one will not open. It is there and will play but won't open and I can't share it or move file.

    Working on a project with 5 movies at the same time andone movie project will not open    I can see it and play it but can't open to work on it or  share or copy it, what should I do?

    WHat version of iMovie?
    ANd for iPad or iPhone?
    Are you having issues opening a video you took on the device?
    OR an issue opening a project you previously created?

  • Open two movies at the same time

    It seems that it is not possible to open two movies (.cp) at
    the same time with Captivate 1 (well you can run a new Captivate
    program an open the second movie) but will it be possible to open
    more than one movie at the same time in Captivate 2?
    Thanks

    Hello hydrosound,
    Whilst you cannot open two Captivate movies in the same
    instance of Macromedia Captivate, you can get around this by simply
    loading another copy of Captivate. I do this all the time and open
    the second project file that way.
    HTH
    Regards,
    Mark

  • My sister bought 2 movies at the same time HELP!!

    My sister bought 2 movies at the same time and when the first one finished downloading the second one deleted but itunes still took the money for a movie she doesn't have
    is there any way to get the movie back without having to buy it again?
    Thanks

    http://support.apple.com/kb/HT1933

  • Can 2 people plug earphones into one iPad to watch a movie at the same time?

    can 2 people plug earphones into one iPad to watch a movie at the same time?

    If you purchase a splitter per the suggestions from the others, be sure that the earphones have their own volume control.  Some, including the absolutely excellent Bose Quiet Comfort "15," rely on the iPad for volume control.
    Also be prepared for the possibility that neither listener will be able to get the sound as loud as he/she wishes.

  • Have created multiclip.  Moved it from browser to viewer.  Saw that the 2 angles were not sync'd.  Held down control/shift on one angle to scroll through clip to put them into sync.  Both angles move at the same time.  What is happening?

    Created Multiclip in browser.  Moved it to the viewer.  Saw that they were not exactly sync'd.  Held down shift/control to move one angle to match the other.  Both angles move at the same time.  What is happening?  I have done this before and have always been able to re-sync my clips to do my edit.

    correction needs to be made to step #14, I typed:
    14) Point to the start or end one of the clips, when you see the icon showing arrows going either way, right click and drag your clips to roughly match up with the timeline selection, then zoom in further and adjust the clip start and end points to match up exactly with the timeline selection start and endpoints.
    Here is the correction, THE CORRECTED PARTS ARE CAPITALIZED:
    14) Point to the start or end OF one of the clips, when you see the icon showing arrows going either way, LEFT-CLICK and drag your clips to roughly match up with the timeline selection, then zoom in further and adjust the clip start and end points to match up exactly with the timeline selection's start and end points.
    Another Correction:
    Originally read:
    Addendum: IF you have 2 files selected and click "Edit" to go to Edit view, it will give you the file of the clip you selected first, not 2nd. You must then go back to MT view, de-select the clip you selected first, then de-select the clip you want to edit, then RE-select the clip you want to edit.
    Here is the the correction, CORRECTED PARTS ARE CAPITALIZED:
    Addendum: IF you have 2 files selected and click "Edit" to go to Edit view, it will give you the file of the clip you selected first, not 2nd. IF YOU WANT TO EDIT THE 2ND FILE YOU SELECTED IN MULTI-TRACK VIEW, You must go back to Multi-track view, de-select the clip you selected first, then de-select the clip you want to edit, then RE-select the clip you want to edit, THEN CLICK "EDIT" TO GO TO EDIT VIEW.

  • How to make a cell populate the same as other cells mac numbers

    does anyone know if theres a command where I can make a cell be the same value as another cell? so i change one cell and it populates the same in others. Thanks!

    Hi appleryan,
    =A1
    in any cell will bring the value of A1 into that cell.
    quinn

  • How to display multiple reports at the same time

    Hi,
    I'm trying to display multiple reports at the same time, each one in separates tabs or windows using Forms 11g 11.1.1.6
    I have a button which has a call to a procedure which makes use of rp2rro library to show the specific reports, for example:
    call_report('report1');
    call_report('report2');
    call_report('report3');
    call_report('report4');
    The main problem is that, just the last report is been displayed.
    Is there some way to display report1, report2 etc in separate tabs or windows ??
    Regards
    Carlos

    You shouldn't have a problem calling different reports at once. As long as you're using Forms 11g they show up in different windows.
    The question is how you are calling the report.
    Here is how I manipulate it.
    After I pass parameters with the ADD_PARAMETER built-in I set some key values (destype, desformat, desname) with the RP2RRO's procedures.
    Finally calling RP2RRO.RP2RRO_RUN_PRODUCT and then WEB.SHOW_DOCUMENT passing the correct procedure parameters the report comes up in a window. If you repeat the above changing the appropriate variables (the report_name in the RP2RRO_RUN_PRODUCT and so on) you can get multiple reports in different windows.

  • How to use multiple languages at the same time for spell checking?

    I use two different languages all the time and words are mostly so different (English and Finnish) that I could have spell checking on for both languages at the same time.
    Now it seem to allow to select only one language at the time and I have to switch back and fort zillion of times per day.

    Thanks for the quick answer.
    The Dictionary Switcher doesn't seem to work with Finnish language, it doesn't detect it at all to be one of the choices although in the Firefox context menu Languages -> Finnish/Finland is shown.
    Also, if it would work, I would need to get rid of multiple EN_* langauges. I just need EN_UK or EN_US, not all 22 different EN_*.
    One option would be to create a custom dictionary, which would have words from both languages. The next task is then to find out how to make this kind of custom ENFI-dictionary, which would have words from both English and Finnish languages.
    Finnish may be a some kind of special case for spell checking anyway, because the support is in its separate plugin:
    http://voikko.sourceforge.net/

  • How to see several windows at the same time?

    I know this is too basic.
    I have 1 window open.
    The tab shows 3 separate items each of which I can click on and see.
    But I don't want to see each window 1 at a time.
    I want to see all 3 items at one time.
    I know how to tile once I see all 3 windows.
    But how do I get to see all 3 at the same time?

    Peter Spier wrote:
    Tabs display one doc at a time. Any viewing method the shows multiple docs uses un-tabbed windows. That button I showed you above is one easy way to change from the tabs to a convenient arrangement of windows.
    So if you have multiple tabs, you can use the views button to arrange them so they are all visible at the same time.
    The Arrange Windows widget in the tool bar is sometimes confusing.
    Selecting any open window makes that the topmost active window; if it's near maximum size, you can't see the others, so this is also confusing.
    How about Window > Arrange > Float All in Windows to separate multiple tabbed open files, followed by Window > Arrange > Tile (or Cascade)?
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • How to get more downloads at the same time

    On my old computer I could download 20 files at the same time (or more, depending on the size). I've got a new computer now but Safari only downloads 4 files at a time: the other files are put on hold and start only when anotehr file has finished downloading.
    How can I enable more downloads at the same time?

    I'm not using any enhancings apps, so... that can't be it. I did go from 10.3.x to 10.4.x, but I guess that's not the point either. Maybe some internetsettings is keeping things from going full throttle...?
    I download from Usenet a lot and downloading multiple files with Safari was very nice: I'd get 20 50 Mb files within a few minutes on my computer. Now I can only get 4 files in that same time (I guess it's a bit faster but not much: I have a VERY fast connection!). Okay, all in all it still only takes half an hour (probably less) to download 3 Gb this way, but I just wonder what's holding Safari back...
    (BTW Downloading big files spread into rars is VERY nice! If I had to download a 3 Gb file as ONE file, it would take a LOT more time...! Makes you wonder why not all companies offer their software (specially larger files) in smaller parts... They used to do that in the early internet days because otherwise you would never ever get that file downloaded on that 56k6 line, but nowadays it still would be great if they offered everything in small parts!

Maybe you are looking for