0 Favourites

How do I appear a arrow show the direction of the ball ?

  • Hi

    How do I appear a arrow show the direction of the ball before i release it ? like what we see in games like billiards

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • You need a mathematical equation to calculate the angle of arrow. as an example if your ball is a "Sprite" and stick's position is mouse pointer then angle of arrow is : "atan((Mouse.Y-Sprite.Y)/(Mouse.X-Sprite.X))". "atan" it teturn the inverse Tangent angle value between mouse pointer and ball

  • Hey AeleaS,

    Two possibilities come to mind that might work.

    To set the angle of the arrow, you can either use the "Set angle towards position" action, or you can just use the "Set angle" action and as the parameter use a handy built in system expression in Construct2 called angle() which will get the angle between two points.

    e.g.

    • angle( 0 , 0 , 100 , 100) = 45
    • angle( Obj.X , Obj.Y , Mouse.X , Mouse.Y ) = The angle of a line from Obj to Mouse.

    Fixed length arrow - (uses one sprite)

    1. Create a sprite arrow pointing right (0 degrees).

    2. Place the hotspot at the tail of the arrow. (This should be the middle of the left edge of the image.)

    3. Set the arrow sprite to the position of the billiard ball (or whatever you're interacting with), and set the angle of the arrow to the angle you want.

    e.g. Below I'll assume we want the arrow to go from a billiard ball to the mouse cursor.

    Event:

    * Every Tick.

    Actions:

    * Set Arrow to position of BilliardBall.

    * Set Arrow angle to look at coord ( Mouse.X , Mouse.Y ).

    Resizable length arrow - (uses two sprites)

    To create an arrow that can change length, you can create the arrow in two parts.

    1. Create the tail, by making a simple 4x4 pixel block filled with a solid color.

    2. Place the hotspot at the left center edge of this sprite.

    3. Create an image point named "headAttachPoint" at the right center edge.

    4. Now create a new sprite that looks like an arrow head pointing right, and place the hotspot at the left edge.

    5. Put the Arrow tail and arrow head sprites in a Construct2 "container".

    6. In the event editor add the following events:

    e.g. Below I'll assume we want the arrow to go from a billiard ball to the mouse cursor.

    Event:

    * Every Tick.

    Actions:

    * Set ArrowTail to position of BilliardBall.

    * Set ArrowTail angle to look at coord ( Mouse.X , Mouse.Y ).

    * Set ArrowTail width to distance( Self.X , Self.Y , Mouse.X , Mouse.Y ) // This sets the arrow length.

    * Set ArrowHead to position of ArrowTail, at image point "headAttachPoint".

    * Set ArrowHead angle to ArrowTail angle.

    Hope that helps out.

  • Hi AeleaS, like this ? [attachment=0:cbl3pp5v][/attachment:cbl3pp5v]

    edit : Oh, fisholith, that's a reply

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)