# Set Width By Aliening Two Image Points

Get help using Construct 2

### » Tue May 06, 2014 11:37 pm

Math Heavy

I'm making a custom character menu but am having trouble getting the width of the hair sprite to function correctly. I have a head sprite and I have a Hair Sprite and both are animations that contain all the individual pieces. That way all I have to do is +/- a frame to cycle all my parts. I have a point where the top of the head meets the hair who's point is where the top of the head should be. So I can not statically set a with for each hair as it would change width every frame of the head and I have now 20 heads and 40 - 60 hair options.

In the image below I drew out what I am trying to do algebraically which is aliening a image point where the temple on the left side of the head should fall. Thus dynamically seating the width of the hair sprite regardless of which head or hair image.

I think I am doing the math right however I still am having issues as the hair is too small but if I know my High School algebra (from a longer time ago than I care to admit) This should give me what I am looking for assuming that the distance form the image point to the center of the sprite is the same distance for the Hair and the Head respectively.

Thank you for your time in helping me solve this.

-edit- Ahhh I made a typo when entering the string, now that I asked for the help

that sets it right. Hope that this will help someone who will need to do the same thing.
You do not have the required permissions to view the files attached to this post.
B
7
S
3
Posts: 113
Reputation: 1,295

### » Wed May 07, 2014 2:00 am

If I understand you correct you have 20 heads with different width and 40-60 hair options which are also different width and you want these to match any of the heads no matter what width?`

If that's the case I think you might be overcomplicating things a bit, if each type of head have a hairline image point you should be able to just set the hair types image point to that image point and then you change the width of the hair to be equal to the head width. Just be sure that the image point is in the centre of the sprite.
B
45
S
12
G
3
Posts: 1,209
Reputation: 7,547

### » Wed May 07, 2014 9:02 pm

nimos100 wrote:If I understand you correct you have 20 heads with different width and 40-60 hair options which are also different width and you want these to match any of the heads no matter what width?`

If that's the case I think you might be overcomplicating things a bit, if each type of head have a hairline image point you should be able to just set the hair types image point to that image point and then you change the width of the hair to be equal to the head width. Just be sure that the image point is in the centre of the sprite.

Unfortunately @nimos100 many of my hair parts have various volumes (female hair). If i have a buzz cut it works very well but anything larger and I loose proportion as having the same width as the head means that the piece is shrunk and does not line up. Which is why I am trying to go the route that I am but its time consuming to make sure that the two points line up every time without a real good control over the points placement.

Any ideas to get this effect that is efficient and accurate would be welcome.
B
7
S
3
Posts: 113
Reputation: 1,295

### » Wed May 07, 2014 9:46 pm

Any ideas to get this effect that is efficient and accurate would be welcome.

Unfortunately I don't think I have any ideas you would like As I would suggest remaking the hair so they are made for fitting your head sprite better. Because it sounds like it would probably take longer time to create the code to fit all the hair parts, than to just recreate them.
B
45
S
12
G
3
Posts: 1,209
Reputation: 7,547

### » Wed May 07, 2014 10:27 pm

nimos100 wrote:
Any ideas to get this effect that is efficient and accurate would be welcome.

Unfortunately I don't think I have any ideas you would like As I would suggest remaking the hair so they are made for fitting your head sprite better. Because it sounds like it would probably take longer time to create the code to fit all the hair parts, than to just recreate them.

Aye but even if I just had 5 hair and 5 head That is 5 hair size code line for head, another 5 for head 2 ect so even that small a system would mean that I would need to hand code 25 actions. With 60 hair styles and 25 heads that becomes 1500 lines of code. Which effects performance and that is just for one race and gender and I still have a fairly large game to append to that one layout.

anyway after playing around I came to something much easier. If for every tick y1 and x1 are not equal; than if y1>x1change the with of Hair till it matches, and do the opposite for <

And It works great and only uses 4 lines

-edit- fixed the hair height at bottom
You do not have the required permissions to view the files attached to this post.