The Daily Click ::. Forums ::. Klik Coding Help ::. Stretch object from one point to another
 

Post Reply  Post Oekaki 
 

Posted By Message

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
26th October, 2012 at 26/10/2012 08:46:18 -

Heyall
I've gots me a flashlight going. It consists of two objects, a circular area for the spot the light is shining set to the mouse) and a beam of light that connects the flashlight to the spot. Basically, all I want to do is stretch that beam of light between the light source and the mouse. currently, Im using the Pythagorean theorem to get the distance, then dividing that by about 300, and setting the X scale of the beam to that. It works in some places, however, at some angles it shrinks to an odd size, and at some it lengthens to an aukward size. the 300 number was just a random guess im sure if the object was a 1pxl width things would be different, but lines arent triangular fools so its about 400 pixels just to be safe, I've no idea what I'm doing and I'm extremely tired ATM so STFU and junk. bahgahah. In case you didn't understand what it was I was just talking about, read it again, and maybe that'd help, if not i can things of sorts. ynah meeeean?

zzzzzzzzzzzzzzzzzzzzzzzz...

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
26th October, 2012 at 26/10/2012 12:47:26 -

Uhh, when you don't use the 1pix then you must divide the thing with it's actuall width at some point.

 
Code me a sausage!

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
26th October, 2012 at 26/10/2012 15:56:22 -

Yeah, thats what I did, except in the wrong place, I figured that out before I went to sleep, except it was still in the wrong place. I started it off with the (1.0/352.0)*Distance formula, though now I think my distance formula is screwed up, because at certain points it's fine, but it seems like specific angles make it goofy.

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
27th October, 2012 at 27/10/2012 02:09:04 -

I always do scale like this : Distance/WidthOftheObject

I am not sure why your angles make it goofy, make sure the hotspot is in the right place.

Here actually i made you an example how i do it.

https://dl.dropbox.com/u/14962632/Public1/ScaleIt.mfa

EDIT: just a note i forgot, in my example i divided width by 32.0 which is the width, but height or Y scale i should have done separately with 6.o since it's only 6 pixel height... so to keep in mind maybe that could be your problem...

Edited by Don Luciano

 
Code me a sausage!

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
27th October, 2012 at 27/10/2012 16:33:31 -

Yeah my problem was purely the distance formula. It was late, and I always forget it, and i was reading sketchy's article where he wrote it as:

Distance = Sqr(((A.x - B.x)*(A.x - B.x)) + ((A.x - B.x)*(A.x - B.x))) 


Sketchy, I am dissapoint...

But yeah, I figured it out after the last post, I just forgot to post that I figured it out mah bad.

HA! Advanced direction object! You're just as mathematically inept as me! BWAHAHAA

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
27th October, 2012 at 27/10/2012 18:32:02 -

Ooops - that's what happens when you copy & paste half an expression and forget to replace the Xs with Ys.
I seem to remember noticing that before, but the article editing function was broken for ages.

Could have used "pow" too:
sqr(((A.x - B.x) pow 2) + ((A.y - B.y) pow 2))

 
n/a

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
27th October, 2012 at 27/10/2012 19:29:16 -


Originally Posted by Sketchy
pow 2



You have just redeemed yourself!

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal
   

Post Reply



 



Advertisement

Worth A Click