none
Shape face mouse position and get position RRS feed

  • Question

  • I want to be able to create a shape that looks in the direction of the mouse. How do i do that by achieving the rotate affect according to the x,y coordinates of the mouse so it looks in the direction of the X,Y coordinates of the mouse? I have already successfully been able to move my character in the direction of the mouse when the button is down.

    Import: WSG416

    And one last thing, how do i get the position of a shape? This would be useful for me since my shape is moving towards the mouse on keydown but on keyup i would like the shape to stop in its current x,y coordinates. I tried this instead:

     

    Sub OnKeyUp

      Shapes.Animate(player,x,y,0)

    EndSub

      Goto start

     

    But rather than stopping in its tracks towards the mouse position, it skips straight to it. Also the code to move shape towards mouse pos on keydown is very inefficient. It is not smooth enough.  Any idea's guys?

    Monday, February 28, 2011 7:21 PM

Answers

  • Here is some answers to your questions:

    To get X position of shape use Shapes.GetLeft(Shape)

    To get Y position of shape use Shapes.GetTop(Shape)

    If you are using Shapes.Animate with 0 duration use Shapes.Move

    To make animation smoother you can try calculate duration from numbers between new and old position.

    Here is sample: WSG416-0


    Sorry My Bad English
    • Marked as answer by SolidiusWolf Wednesday, March 2, 2011 9:37 AM
    Monday, February 28, 2011 8:03 PM