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 8601877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:56:46+00:00 2026-06-12T01:56:46+00:00

The following is my code, it’s working properly, it’s just that the animation of

  • 0

The following is my code, it’s working properly, it’s just that the “animation” of a moving line in the line if (guidelineOn) is not smooth. The drawRect is being called every 0.01 seconds.

if (guideLineOn)
{
[self drawGuidanceLineAtPoint:CGPointMake((65+guideLineOffset)*scalingF, 98*scalingF) withAlpha:paramAlpha];
}

It’s kind of laggy and sometimes interferes with the user input. How do I resolve this? New to this so open to suggestions.

Thanks in advance for your help.

Pier.

- (void)drawRect:(CGRect)rect
{
scalingF = 1.0; // default : iPhone

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    scalingF = IPAD_SCALING_FACTOR;
}

if (guideLineOn)
{
    [self drawGuidanceLineAtPoint:CGPointMake((65+guideLineOffset)*scalingF, 98*scalingF) withAlpha:paramAlpha];
}

// draw staff line
[self drawStaffLineFrom:CGPointMake(65*scalingF, 98*scalingF) toPoint:CGPointMake(420*scalingF, 98*scalingF)];
[self drawStaffLineFrom:CGPointMake(420*scalingF,108*scalingF) toPoint:CGPointMake(420*scalingF, 50*scalingF)];
[self drawStaffLineFrom:CGPointMake(415*scalingF,108*scalingF) toPoint:CGPointMake(415*scalingF, 50*scalingF)];

// cycle through all the static images to draw tbd
float offSet = 0.0;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    offSet += 50.0; // to adjust the metronome down
}

if (metronomeImage)
{

    [metronomeImage drawInRect:CGRectMake(410.0f*scalingF, 195.0f*scalingF+offSet, metronomeImage.size.width*scalingF, metronomeImage.size.height*scalingF)];
}

if (circlesImage)
{
    [circlesImage drawInRect:CGRectMake(400.0f*scalingF, 255.0f*scalingF+offSet, circlesImage.size.width*scalingF, circlesImage.size.height*scalingF)];
}

for (Note * v in notesArray)
{
    UIImage * noteImage = [UIImage imageNamed: v.imageName];
    [noteImage drawInRect:CGRectMake(v.notePlacement.x*scalingF, v.notePlacement.y*scalingF, noteImage.size.width*scalingF, noteImage.size.height*scalingF)];
}

if (!clearDisplay) 
{
    // draw the arrows
    for (int i=0; i < arrowsToDrawArray.count; i++)
    {
        Arrow * arrowObj = [arrowsToDrawArray objectAtIndex:i];
        UIColor * colourOfArrow = [arrowObj colourOfArrow]; // colour determines whether right or wrong
        CGPoint p = [arrowObj arrowPlacement];
        p.x = p.x*scalingF;
        p.y = p.y*scalingF;

    //    CGPoint p = [val CGPointValue]; 
        [self drawRooftopAtTopPointof:p colour:colourOfArrow lineJoin:kCGLineJoinMiter];
    }

    // draw the ties
    for (int j=0; j < tiePointsArray.count; j++)
    {
        CGPointPair * tiePairToDraw = [tiePointsArray objectAtIndex:j];
        CGPoint firstPt = [tiePairToDraw firstPoint];
        firstPt.x = firstPt.x *scalingF;
        firstPt.y = firstPt.y *scalingF;

        CGPoint secondPt = [tiePairToDraw secondPoint];
        secondPt.x = secondPt.x *scalingF;
        secondPt.y = secondPt.y *scalingF;

        [self drawPseudoCurveFromPoint:firstPt toPoint:secondPt];
    }

    // bool perfect = true;
    // int noOfNotesHit = 0;

    // draw the tick/cross/arrow
    for (int k=0; k < answerObjArray.count; k++)
    {
        Answer * ansObj = [answerObjArray objectAtIndex:k];

        if (ansObj.hit)
        {
           // noOfNotesHit++;

            if (ansObj.earlyOrLate == -1) // early, draw right pointing arrow
            {
                UIImage * arrowImage = [UIImage imageNamed: @"arrowright.png"];
                [arrowImage drawInRect:CGRectMake((ansObj.xPosition-(0.5*arrowImage.size.width))*scalingF, 125*scalingF, arrowImage.size.width*scalingF, arrowImage.size.height*scalingF)];
               // perfect = false;
            }
            else if (ansObj.earlyOrLate == 1) // late, draw left pointing arrow
            {
                UIImage * arrowImage = [UIImage imageNamed: @"arrowleft.png"];
                [arrowImage drawInRect:CGRectMake((ansObj.xPosition-(0.5*arrowImage.size.width))*scalingF, 125*scalingF, arrowImage.size.width*scalingF, arrowImage.size.height*scalingF)];
                //perfect = false;
            }
            else // perfect!
            {
                // draw a tick
                UIImage * tickImage = [UIImage imageNamed: @"tick.png"];
                [tickImage drawInRect:CGRectMake((ansObj.xPosition-(0.5*tickImage.size.width))*scalingF, 125*scalingF, tickImage.size.width*scalingF, tickImage.size.height*scalingF)];
            }

        }
        else
        {
            // draw a cross
            UIImage * crossImage = [UIImage imageNamed: @"cross.png"];
            [crossImage drawInRect:CGRectMake((ansObj.xPosition-(0.5*crossImage.size.width))*scalingF, 125*scalingF, crossImage.size.width*scalingF, crossImage.size.height*scalingF)];
            //perfect = false;
        }

    }

}
else 
{
    // draw nothing
    clearDisplay = false; 
}

}
  • 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-06-12T01:56:47+00:00Added an answer on June 12, 2026 at 1:56 am

    Here’s my Core Animation solution for those interested.

    - (void) animateRedLine: (float) alphaParam
    {
    [self.view addSubview:self.redlineImageView];
    /* Start from top left corner */
    [self.redlineImageView setFrame:CGRectMake(65.0f*scalingF,
                                              50.0f*scalingF,
                                              self.redlineImageView.image.size.width*scalingF,
                                              self.redlineImageView.image.size.height*scalingF*2)];
    
    [self.redlineImageView setAlpha:alphaParam];
    
    [UIView beginAnimations:@"redLineAnimation"
                    context:( void *)self.redlineImageView];
    
    /* 3 seconds animation */
    [UIView setAnimationDuration:noOfBeatsInBar*timeInSecondsForOneBeat];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    /* Receive animation delegates */
    [UIView setAnimationDelegate:self];
    
    [UIView setAnimationDidStopSelector:
     @selector(imageViewDidStop:finished:context:)];
    
    /* End at the bottom right corner */
    [self.redlineImageView setFrame:CGRectMake((65.0f+LENGTH_OF_BAR)*scalingF,
                                              50.0f*scalingF,
                                              self.redlineImageView.image.size.width*scalingF,
                                              self.redlineImageView.image.size.height*scalingF*2)];
    
    //[self.redlineImageView setAlpha:0.0f];
    
    [UIView commitAnimations];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following code climate analysis, I found that my controllers are not DRY as it
Following code found that output results is not the order, not from small to
Following code transfer file successfully, but does not print in lable that it has
Following code is working with Firefox browser but onClick is not working with Chrome
Following code works ok, except that it not zoom to the given points. If
following code is write are not: selenium.GetEval(document.getElementsByTagName('a')[1].innerText); actually other scripts are working fine like
Following code for passing an object to event handler is not working: $('a.another').live('click', function(e,
following code works perfectly on FF and Chrome but not in IE8. $(window).keyup(function(e) {
Following code work for visualizing a molecule on a JPanel except it does not
Following code does not work - new Date(2011-10-01) What is the format of specifying

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.