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

  • SEARCH
  • Home
  • 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 709467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:30:27+00:00 2026-05-14T04:30:27+00:00

I am using the accelerometer to move a few UIImageViews around the screen, at

  • 0

I am using the accelerometer to move a few UIImageViews around the screen, at the moment the accelerometer only works when a NSTimer is at 0, this is fine. I would also like to make the accelerometer stop again when a different function happens.

here is my code at the moment:

-(BOOL) accelerometerWorks {
 return time == 0;
}

-(void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{
 if(![self accelerometerWorks]) return;
 valueX = acceleration.x*25.5;



 int newX = (int)(ball.center.x +valueX);
 if (newX > 320-BALL_RADIUS)
  newX = 320-BALL_RADIUS;
 if (newX < 0+BALL_RADIUS)
  newX = 0+BALL_RADIUS;


 int XA = (int)(balloonbit1.center.x +valueX);
 if (XA > 320-BALL_RADIUS)
  XA = 320-BALL_RADIUS;
 if (XA < 0+BALL_RADIUS)
  XA = 0+BALL_RADIUS;


 int XB = (int)(balloonbit2.center.x +valueX);
 if (XB > 320-BALL_RADIUS)
  XB = 320-BALL_RADIUS;
 if (XB < 0+BALL_RADIUS)
  XB = 0+BALL_RADIUS;

 int XI = (int)(balloonbit3.center.x +valueX);
 if (XI > 320-BALL_RADIUS)
  XI = 320-BALL_RADIUS;
 if (XI < 0+BALL_RADIUS)
  XI = 0+BALL_RADIUS;

 int XJ = (int)(balloonbit4.center.x +valueX);
 if (XJ > 320-BALL_RADIUS)
  XJ = 320-BALL_RADIUS;
 if (XJ < 0+BALL_RADIUS)
  XJ = 0+BALL_RADIUS;


 int XE = (int)(balloonbit5.center.x +valueX);
 if (XE > 320-BALL_RADIUS)
  XE = 320-BALL_RADIUS;
 if (XE < 0+BALL_RADIUS)
  XE = 0+BALL_RADIUS;


 int XF = (int)(balloonbit6.center.x +valueX);
 if (XF > 320-BALL_RADIUS)
  XF = 320-BALL_RADIUS;
 if (XF < 0+BALL_RADIUS)
  XF = 0+BALL_RADIUS;


 int XH = (int)(balloonbit8.center.x +valueX);
 if (XH > 320-BALL_RADIUS)
  XH = 320-BALL_RADIUS;
 if (XH < 0+BALL_RADIUS)
  XH = 0+BALL_RADIUS;


 ball.center = CGPointMake (newX, 429);
 balloonbit1.center = CGPointMake (XA, 429);
 balloonbit2.center = CGPointMake (XB, 426);
 balloonbit3.center = CGPointMake (XI, 410);
 balloonbit4.center = CGPointMake (XJ, 415);
 balloonbit5.center = CGPointMake (XE, 409);
 balloonbit6.center = CGPointMake (XF, 427);
 balloonbit8.center = CGPointMake (XH, 417);

}

This all works fine, i would now like to stop the accelerometer from working, using the same

accelerometerWorks method or a new method, accelerometerWontWork.

This is the code that when it is called i would like the accelerometer to stop. (it is very long so i wont put all of it there, but its all the same throughout):

-(void) checkCollision{

 if (CGRectIntersectsRect(pinend.frame, balloonbit1.frame)){
  if (balloonbit1.frame.origin.y > pinend.frame.origin.y){
   [maintimer invalidate];
   levelfailed.center = CGPointMake (160, 235);
  }
 }
 if (CGRectIntersectsRect(pinend.frame, balloonbit2.frame)){
  if (balloonbit2.frame.origin.y > pinend.frame.origin.y){
   [maintimer invalidate];
   levelfailed.center = CGPointMake (160, 235);
  }
 }
 if (CGRectIntersectsRect(pinend.frame, balloonbit3.frame)){
  if (balloonbit3.frame.origin.y > pinend.frame.origin.y){
   [maintimer invalidate];
   levelfailed.center = CGPointMake (160, 235);
  }
 }
}

I understand that i may have to turn this into a BOOL. Thats fine.

If i haven’t explained it well please say and i will re write it.

Thanks!
Harry.

  • 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-14T04:30:28+00:00Added an answer on May 14, 2026 at 4:30 am
    accelManeger = [UIAccelerometer sharedAccelerometer];
    accelManeger.delegate = nil;
    

    that will stop you receiving events. Then set yourself as the delegate when you want to start again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.