Draw a line from actor's X,Y to mouse's X,Y

mza1979mmza1979m Member Posts: 27
edited November -1 in Working with GS (Mac)
Is there a way I can have the game draw a straight line (even if it's dashed) from a given actor to the mouse's X,Y coordinates when the mouse button is held down? I'd also like the line to move as the mouse moves and to disappear when the mouse button is released. Think of a pool game as an example.
Fat chance?

Comments

  • mza1979mmza1979m Member Posts: 27
    Well... after playing around with it for a few minutes, the closest I could come to was:
    When mouse is held down (on an invisible background),
    Every 0.1 seconds, spawn actor2 (2 pixels X 2 pixels) at location of main actor1

    In actor2, I have a "Move To" specifying movement towards mouse X,Y at default speed (300).
    When actor2's X,Y = mouse X,Y: destroy actor2

    That way, I have a constant stream of dots travelling at high speeds towards where the user clicks/touches, which simulates a line. It's not perfect but it's the best I could do.
    But if someone has a better idea, I'd definitely be interested in hearing it.
  • AjBlueAjBlue Member Posts: 215
    i think you need to use vector to angle in the expression editor
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Using the right math you should be able to have an actor move and grow with the rotation based on your mouse position. I of course do not know all of the math stuff so good luck with that. You idea sounds like it may work also but spawning like that has the potential to eat up your memory usage.
  • HachikoHachiko Member Posts: 330
    Done a little template now, should show you everything math side
    http://www.megaupload.com/?d=0UGOU2QO
  • mza1979mmza1979m Member Posts: 27
    AjBlue & tenrdrmer, thanks so much for your help.
    Hachiko, that's exactly what I needed. Thank you so much for taking the time.
  • allornothingallornothing Member, PRO Posts: 126
    @Hachiko - this is a few months old, but the template you made was exactly what i needed to understand - thanks muchly!
Sign In or Register to comment.