linking falling dots together by a straight line ?!

bartvicicbartvicic Member, PRO Posts: 14

i'm working on a project that has dots falling from top to bottom.
the player is supposed to connect them together by dragging his finger from one dot to another..
i've been struggling to make it happen, i don't know how to logically program the actual link. everything else is more or less done.

please help! :smile:

Comments

  • bjandthekatzbjandthekatz Orlando, FlMember Posts: 1,375

    What do you mean connect them together? Do you want to add a line between them or do you want them to combine into a bigger dot?

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2014

    @bartvicic said:
    i don't know how to logically program the actual link.

    It will just be a box, the length will be the magnitude of dot 1 - dot 2, the rotation will be the vector to angle of dot 1 - dot 2 and the position will be: x = ((magnitude of dot 1 to dot 2) /2) * cos(vector to angle of dot 1 -to 2) and y = ((magnitude of dot 1 - dot 2) /2) * sin(vector to angle of dot 1 - 2).

    Of course that all might be wrong ! :) I'll test it out a bit later, it should be something like that.

  • SocksSocks London, UK.Member Posts: 12,822

    Actually dump the ((magnitude of dot 1 to dot 2) /2) * cos(vector to angle of dot 1 -to 2) stuff, you can locate the x and y centre between two objects with a more simple . . .

    (( Dot 2 X minus Dot 1 X )/2) + Dot 1 X
    (( Dot 2 Y minus Dot 1 Y )/2) + Dot 1 Y

    Anyhow, I've made you a quick demo, three falling dots connected by lines - forming an ever-changing triangle:

    Link: https://www.mediafire.com/?2q3oxuzu9hchazc

  • bartvicicbartvicic Member, PRO Posts: 14

    yes i just want to link them. its very helpful, thanks. but my dots spawn above the visible scene area and the fall out of the scene, how do i constrain their attributes if there is always a different dot?

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2014

    @bartvicic said:
    but my dots spawn above the visible scene area . . .

    Then spawn them above the visible scene area.

  • bartvicicbartvicic Member, PRO Posts: 14

    @Socks said:
    Then spawn them above the visible scene area.

    I'm sorry i should explain this differently. there are always new dots spawning in a random place above the scene and falling down and eventually out of the scene, so its always a new dot and a new link connecting the new one with the old..

Sign In or Register to comment.