Construct 2 is being retired on 1 Jul, 2021. We strongly recommend upgrading to Construct 3.
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 the Sine behavior - types example in the Start dialog.
- Active on start
- If No, the behavior will have no effect until the Set active action is used.
- The 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. Forwards/backwards moves the object in a straight line back and forth along the angle the object is facing at, like an angled Horizontal mode.
- The 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.
- The duration, in seconds, of one complete back-and-forth cycle.
- Period random
- A 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 offset
- The 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 random
- A 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.
- The 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 random
- A 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.
- Compare magnitude
- Compare the current magnitude of the movement.
- Compare movement
- Compare the current movement property of the behavior.
- Compare period
- Compare the current period of the movement, in seconds.
- Compare wave
- Compare the current wave property of the behavior.
- Is active
- True if the behavior is active.
- Set active
- Enable or disable the behavior. When disabled, the behavior does not affect the object at all.
- Set cycle position
- Set the progress through one cycle of the chosen wave, from 0 (the beginning of the cycle) to 1 (the end of the cycle). For example setting the cycle position to 0.5 will put it half way through the repeating motion.
- Set magnitude
- Set the current magnitude of the cycle. This is in pixels when modifying the size or position, and degrees when modifying the angle.
- Set movement
- Change the movement type of the behavior, e.g. from Horizontal to Size.
- Set period
- Set the duration of a single complete back-and-forth cycle, in seconds.
- Set wave
- Change the wave property of the behavior, choosing a different wave function to be used to calculate the movement.
- Update initial state
- The Sine behavior records the object's initial state upon its creation, and always oscillates relative to that, even if it is deactivated and later activated after the object has been modified. If the object changes and you wish for the Sine behavior to oscillate relative to the new state instead of its state upon creation, use this action to reset the initial state to the object's current state.
- Return 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.
- Return the current magnitude of the cycle. This is in pixels when modifying the size or position, and degrees when modifying the angle.
- Return the current period of a single complete back-and-forth cycle in seconds.
- Return 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.
Construct 2 Manual
You are here:
Search this manual:
This manual entry was last updated on 9 Jun, 2020 at 13:12