[REQUEST] Sine action "RESET"

0 favourites
From the Asset Store
11 loops of RPG, chiptune/8-bit music. Suitable for any pixel art game.
  • Hello C2 development team,

    I'd like to point out a missing feature of the Sine Behavior:

    I'm missing the Sine Reset action. Once the Sine is activated it oscillates back and fort to the eternity. If set to inactive and back to active, it starts exactly from its last value, which is not always wanted.

    For example, if I would like to perform just a quarter period movement (progress 0 to 1), I'm using a condition to stop, i.e. inactivate the Sine behavior. Later, I'd like to repeat on the same object that quarter period movement from the beginning (progress 0 to 1 again), and not as noted from the last progress point (1 through 0 to -1). For now it appears to be impossible...?!

  • +1

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • +2

  • +3

  • Hi again, I've taken a look at the Sine Behavior code. If I'm not wrong, it should be enough to add following code to add a Reset action:


    <font color=blue>AddAction(5, af_none, "Reset", "", "{my} <b>Reset</b>", "Reset the wave function.", "ResetWave");</font>


    <font color=blue>Acts.prototype.ResetWave = function (){this.i = 0;};</font>

    I've tested it. It works as expected. On Reset, the Sine function starts at 0. Maybe you could test it too, and it could be added to the next C2 issue??

  • I've just experimented with that Sine Reset function and noticed, that the period offset and period random offset were not considered. So here is an extended code (actually a copy-paste from the Sine initializing function), which considers those two:


    Acts.prototype.ResetWave = function ()

    { if (this.period === 0) this.i = 0;

       else { // if some period offset is given, it should reset to that offset

         this.i = (this.properties[5] / this.period) * _2pi;

         this.i += ((Math.random() * this.properties[6]) / this.period) * _2pi;



    I've compiled an example with the extended Sine behavior, which can be seen here. The reset here demonstrates repeatable 0.25 to 0.75 sine cycle, instead of continually going back and fort.

    (Of course in that particular case, there could be a workaround with an ABS() function for the falling (minus) sine function):


  • This is just what I needed, thanks a lot!

  • remember to never update your OOTB behaviors and plugins. Always make a new one like CustomSine or MySine.

  • Not sure if I'm being dumb, but is it also possible to decide which direction the sine starts with? I'm using it to have alien ships fly in a bit of a pattern, but sometimes I want them to start off moving left rather than right. Always seems to start in the same direction.

  • farflamex

    When you place some sprites down with Sine behaviour, you can change each ones "Period offset", which is how far it is through it's cycle I think. As with the topic itself, it's currently not possible to change where it is in it's movement, which hopefully will get officially implemented :P

    Hope this helps!

  • Thumbs up for this request from me then, because I'd like to see that added. At least I can currently set it when I create my ships, which solves the current problem, but I can see how handy it would be to be able to reset and reposition it during gameplay.

  • I would prefer being able to set the current position of the movement (in relation to the amplitude), for instance, set it to 0.5 to make it go to the halfway point. This way, if I want to reset, I can just set it to 0. I'd also be able to synchronize it to other systems.

    For instance, say you have a rope dangling from the ceiling. You grab the rope and it starts lowering. As long as there is still rope, some random platform (with the sine movement) moves around. When the rope ends, the platform stops. When you let go of the rope, it retracts, and the platform does it's motion backwards. In reality it's all tied to a single variable, 0 being the rope fully retracted and 1 being the rope fully extended.

  • +1 for me. Would be nice to able to reset the sine.

  • +1 for me two. Please, please scirra add the reset function to the sine.

    I would like to submit my game with this function to scirra arcade :)

  • I want a sine-reset, too. Right now i'm using it to shake a sprite.

    I currently solve it by saving the sprites position at the point i start the sine behaviour, then on disabling i restore it via two instance variables posX & posY

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