Change variable Time in animation

Example:

Retardo=5000

Hojadeanimacion =

{

    width = 76,

    height = 76,

    numFrames = 270,

    sheetContentWidth = 760,

    sheetContentHeight = 2052

}

Secuenciaexplosionroja = graphics.newImageSheet( “Secuenciabombaroja.png”, Hojadeanimacion )

sequenceData =

{

    name=“Bombaroja”,

    start=1,

    count=270,

    time=Retardo,         

    loopCount = 1,    

    loopDirection = “forward”,    

}

Animar = display.newSprite(Secuenciaexplosionroja, sequenceData )

Animar.x = 330

Animar.y = 200

Retardo=10000 (Don’t work)

Once the sprite sheet has been declared, the sequence and the location of the animation, in what way do I access the variable "Time"to change its value?

I have tried assigning another variable and replacing the number. But it does not work. It’s like the initial value can not be changed. I have looked in the help and I could not find an example of how to change the value.

The animation works wonders but I can not change the TIme value once the sequence is declared.

Wrong approach. 

You change the time.scale of the playing sprite:

https://docs.coronalabs.com/api/type/SpriteObject/timeScale.html

I appreciate your response. But it does not seem like a convincing solution. I was looking for something else.

Here is simple solution for your issue. Don’t use animation! :slight_smile:

If you want to make dynamic changes in your animation you should use scripts instead of animation. It doesn’t matter what kind of animation you want to achieve.

Here is example of natural looking smooth animation in a few lines of C# script:

  1. public float minimum = 10.0F;
  2. public float maximum = 20.0F;
  3. public float duration = 5.0F;
  4. private float startTime;
  5. void Start() {
  6. startTime = Time.time;
  7. }
  8. void Update() {
  9. float t = (Time.time - startTime) / duration;
  10. transform.position = new Vector3(Mathf.SmoothStep(minimum, maximum, t), 0, 0);
  11. }

You can easily change parameters of the animations for different objects.

Information is taken from:Bitcohen.Cheer.

Hi @Topazygg and welcome to the Corona Labs community forums. Just a quick reminder, our forum rules ask that you not use different fonts, excessive formatting, etc. Code should be formatted using the <> code tag in the row with the Bold and Italic buttons or inside bbcode style like:

[lua]...paste your code here...[/lua]

Speaking of Code, Corona uses Lua, so providing examples in C# isn’t very helpful to Corona developers. Also the various API calls don’t translate well.

Thanks for understanding!

Rob

Oh,sorry.I will. :wink:

Wrong approach. 

You change the time.scale of the playing sprite:

https://docs.coronalabs.com/api/type/SpriteObject/timeScale.html

I appreciate your response. But it does not seem like a convincing solution. I was looking for something else.

Here is simple solution for your issue. Don’t use animation! :slight_smile:

If you want to make dynamic changes in your animation you should use scripts instead of animation. It doesn’t matter what kind of animation you want to achieve.

Here is example of natural looking smooth animation in a few lines of C# script:

  1. public float minimum = 10.0F;
  2. public float maximum = 20.0F;
  3. public float duration = 5.0F;
  4. private float startTime;
  5. void Start() {
  6. startTime = Time.time;
  7. }
  8. void Update() {
  9. float t = (Time.time - startTime) / duration;
  10. transform.position = new Vector3(Mathf.SmoothStep(minimum, maximum, t), 0, 0);
  11. }

You can easily change parameters of the animations for different objects.

Information is taken from:Bitcohen.Cheer.

Hi @Topazygg and welcome to the Corona Labs community forums. Just a quick reminder, our forum rules ask that you not use different fonts, excessive formatting, etc. Code should be formatted using the <> code tag in the row with the Bold and Italic buttons or inside bbcode style like:

[lua]...paste your code here...[/lua]

Speaking of Code, Corona uses Lua, so providing examples in C# isn’t very helpful to Corona developers. Also the various API calls don’t translate well.

Thanks for understanding!

Rob

Oh,sorry.I will. :wink: