moveShapeAngle

moveShapeAngle( referenceShape, distance, angle, shapeToMove)

Moves the shapeToMove relative to the referenceShape the given distance away and at the given angle (which must be in degrees, not radians).

The location of the shape is saved into the database and automatically associated with the current session, trial and phase (if applicable).

Note that just like the moveShape(…) function, using moveShape2 creates the dedicated “moved” event in the Events table within the database.


Note that if you need to move more than one shape you should look at the moveShapesOnCircle() method, it may be more useful and simpler to use as well.


When using this function, it can be handy to have a reference diagram of the basic angles:

Arguments

referenceShape

- the reference shape (this shape is not moved).

distance

- the  distance away from the referenceShape to move the shapeToMove.

This value may be either absolute or a percent; if it is a percent then it is a percentage of the larger of the screen’s width.

Conceptually, if it is simplier you may think of this as the radius of the imaginary circle that the shapeToMove is being placed on; of course, if this is not simpler conceptually then just ignore this entire sentence!

angle

- The angle (in degrees) which the shape will be moved to.

shapeToMove

- the shape that will be moved relative to the referenceShape

Returns

The shape that was moved (the shapeToMove argument).

Example

The following displays a black circle in the centre of the screen, and then moves the red circle all the way around it:

// Define our circle

define type of circle CircleType

       radius = 50                // The circle’s diameter is 100

       IsVisible = false        // hide it so it only appears once we’ve positioned it

end circle


// Create our reference circle and set its colour to black

define refCircle = create CircleType

refCircle.Colour = #000000

refCircle.X = 50%

refCircle.Y = 50%


// Create our circle to move and set its colour to red

define secondCircle = create CircleType

secondCircle.Colour = #FF0000


define angle = 0

while( angle < 360 )

       moveShapeAngle(refCircle, secondCircle, 200, angle)

       refCircle.IsVisible = true

       secondCircle.IsVisible = true


       wait for 20ms

       angle += 1

end while


print(“Done!”)