The
Sine behavior can adjust an object's properties (like its position, size or angle) back and forth according to an oscillating
sine wave. This can be used to create interesting visual effects. Despite the name, alternative wave functions like 'Triangle' can also be selected to create different effects. A visualisation of the different wave types can be found on
Wikipedia.
For examples of the Sine behavior's different modes, see
Sine behavior - types.capx in the Examples folder in Construct 2's install directory.
Sine properties
Active on startIf
No, the behavior will have no effect until the
Set active action is used.
MovementThe Sine behavior has eight different modes:
Horizontal moves the object left and right on the X axis
Vertical moves the object up and down on the Y axis
Size makes the object grow and shrink
Width stretches the object wider and narrower
Height stretches the object taller and shorter
Angle rotates the object clockwise and anticlockwise
Opacity oscillates the object opacity. Note object opacities can never go less than 0 or greater than 100.
Value only does not modify the object. It simply stores the oscillating value which can be accessed by the
Value expression. This can be useful to create custom effects or modify any other object or behavior property based on the sine behavior.
WaveThe wave function used to calculate the movement. For a visualisation see
this Wikipedia diagram.
Sine - the default smooth oscillating motion based on a sine wave.
Triangle - a linear back-and-forth motion.
Sawtooth - linear motion with a jump back to start.
Reverse sawtooth - reverse linear motion with a jump back to start.
Square - alternating between the two maximum values.
PeriodThe duration, in seconds, of one complete back-and-forth cycle.
Period randomA random number of seconds added to the period for each instance. This can help vary the appearance when a lot of instances are using the Sine behavior.
Period offsetThe initial time in seconds through the cycle. For example, if the period is 2 seconds and the period offset is 1 second, the sine behavior starts half way through a cycle.
Period offset randomA random number of seconds added to the period offset for each instance. This can help vary the appearance when a lot of instances are using the Sine behavior.
MagnitudeThe maximum change in the object's position, size or angle. This is in pixels for position or size modes, or degrees for the angle mode.
Magnitude randomA random value to add to the magnitude for each instance. This can help vary the appearance when a lot of instances are using the Sine behavior.
Sine conditions
Compare magnitudeCompare the current magnitude of the movement.
Compare movementCompare the current movement property of the behavior.
Compare periodCompare the current period of the movement, in seconds.
Compare waveCompare the current wave property of the behavior.
Is activeTrue if the behavior is active.
Sine actions
Set activeEnable or disable the behavior. When disabled, the behavior does not affect the object at all.
Set magnitudeSet the current magnitude of the cycle. This is in pixels when modifying the size or position, and degrees when modifying the angle.
Set movementChange the movement type of the behavior, e.g. from
Horizontal to
Size.
Set periodSet the duration of a single complete back-and-forth cycle, in seconds.
Set waveChange the wave property of the behavior, choosing a different wave function to be used to calculate the movement.
Sine expressions
CyclePositionReturn a value from 0 to 1 representing the progress through the current cycle. For example, exactly half way through a cycle this returns 0.5.
MagnitudeReturn the current magnitude of the cycle. This is in pixels when modifying the size or position, and degrees when modifying the angle.
PeriodReturn the current period of a single complete back-and-forth cycle in seconds.
ValueReturn the current oscillating value. This will alternate as a positive and negative value centered on zero. This is useful to create custom effects when in
Value only mode.