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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:18:15+00:00 2026-06-14T13:18:15+00:00

The question I am about to ask could be somewhat challenging. I will try

  • 0

The question I am about to ask could be somewhat challenging. I will try to make this as clear and cohesive as possible.

I am currently making a game, in which I have a ‘laser ring,’ as shown here:

A laser ring

This laser ring, when prompted, will fire a ‘grappling hook’ which is simply the image shown below. This image’s frame.width property is adjusted to make it fire (lengthen) and retract (shorten.) It starts at a width of 0, and as the frames progress, it lengthens until reaching the desired point.

enter image description here

This grappling hook, when fired, should line up with the ring so that they appear to be one item. Refer to the image below for clarity:

enter image description here

*Note that the grappling hook’s width changes almost every frame, so a constant width cannot be assumed.

Something else to note is that, for reasons that are difficult to explain, I can only access the frame.center property of the grappling hook and not the frame.origin property.

So, my question to you all is this: How can I, accessing only the frame.center.x and frame.center.y properties of the grappling hook, place it around the laser ring in such a way that it appears to be seamlessly extending from the ring as shown in the above image – presumably calculated based on the angle and width of the grappling hook at any given frame?

Any help is immensely appreciated.

  • 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-14T13:18:16+00:00Added an answer on June 14, 2026 at 1:18 pm

    OK, I’ve done this exact same thing in my own app.

    The trick I did to make it easier was to have a function to calculate the “unitVector” of the line.

    i.e. the vector change in the line based on a line length of 1.

    It just uses simple pythagorus…

    - (CGSize)unitVectorFromPoint:(CGPoint)start toPoint:(CGPoint)end
    {
        //distance between start an end
        float dX = end.x - start.x;
        float dY = end.y - start.y;
        float distance = sqrtf(dX * dX + dY * dY);  // simple pythagorus
    
        //unit vector is just the difference divided by the distance
        CGSize unitVector = CGSizeMake(dX/distance, dY/distance);
    
        return unitVector;
    }
    

    Note… it doesn’t matter which way round the start and end are as squaring the numbers will only give positive values.

    Now you can use this vector to get to any point along the line between the two points (centre of the circle and target).

    So, the start of the line is …

    CGPoint center = // center of circle
    CGPoint target = // target
    float radius = //radius of circle
    
    float dX = center.x - target.x;
    float dY = center.y - target.y;
    
    float distance = sqrtf(dX * dX + dY * dY);
    
    CGSize unitVector = [self unitVectorFromPoint:center toPoint:target];
    
    CGPoint startOfLaser = CGPointMake(center.x + unitVector.x * radius, center.y + unitVector.y * radius).
    
    CGPoint midPointOfLaser = CGPointMake(center.x + unitVecotr.x * distance * 0.5, center.y + unitVector.y * distance * 0.5);
    

    This just multiplies the unit vector by how far you want to go (radius) to get to the point on the line at that distance.

    Hope this helps 😀

    If you want the mid point between the two points then you just need to change “radius” to be the distance that you want to calculate and it will give you the mid point. (and so on).

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

Sidebar

Related Questions

I want to ask a question about UITableViewCell. Apparently, this is what I want
i would like to ask a question about @UsesJAXBContext annotation in jax-ws. I try
i'm just curious. so i ask this particular question about SQLite. I haven't use
You can read this question where I ask about the best architecture for a
I'm revisiting and re-implementing the code that caused me to ask this question about
Most questions revolving around the title of this post ask about making Hibernate, or
Yesterday I ask a question about videos for websites, and I get response with
i want to ask a question about how to do paging in ASP.net coding
I want to ask a question about the Contacts on objective C. I am
I want to ask a question about the iPhone application. I am writing a

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.