Question about scripting.

Hello everyone,

 

I have a question about scripting. I'am about to work on my first animation and do have a little problem now.

I have two parts that I want to run through part after part (it may ends up with 3 parts later). So when the animation of part 1 is finished then it should go to part 2. But so far, the two animations are always played simultaneously.

Is there anyway to have some kind of break included? Or state that this fragment of code should only be run, after something else is completly finished?

 

I have read the included instrunctions, but have not found a solution so far. Or have I missed something? Would this even be possible?

 

cheers Asound

8,126 views 6 replies
Reply #1 Top

If you mean do something for the first 50% of the time and then something else for the next 50% of the time I suggest an IF statement using the percentage completed.  You could also make use of the globals1-8 and store a value when the first part has been finished and use that with an if.

Reply #2 Top

I have an IF statement at the beginning, it just checks if 1 euqals 1. I just did it that way, to have the first part of code in brackets. At the end of this part I store a number into a global variable.

The second part is also in brackets with an IF statement before. It only runs that part, after the specific number has been set, at the end of part 1. But the animation of those two parts are always played simultaneously.

For my plan, I really need to have part two played only, after the animation of part one is fully finished. I want to have the window unfold/fold with two steps. And if needed I would add a third step, where the complete folded window just disappears/appears in a stylish way.

 

How do I use "percent"? Which numbers does it hold?

Just using

"

IF

PERCENT

50

=

{

}

"

is not working. But I'am not shure if the first animation would even be over till then.

Reply #3 Top

PERCENT is a value between 0 and 100.  This value increases for open / restore animations and decreases for close / minimize animations.  So 100 means window should now be fully visible and 0 means window should now be invisible and the values between indicate how far through the animation you should be.

So if you wanted code to run for the first half and then something else in the other half you might do it like this

 

IF

PERCENT

50

<=

{

; Do work in here for the animation between 0 and 50 %

 

 

END

}

 

; Do work here for the animation between 50 and 100%

 

END

---

Most animations would reset the grid via SetupGrid before the if statement as it is easier to do animations if you start from a fixed position and then adjust it based on the % of the animation complete.

Reply #4 Top

When I dont use brackets in the second part, the animation just plays along with the first animation again. While I just define with the first if-statement in front of the first part, how much time I got for this animation.

But if the second part is also in brackets and should only play after 50 percent, the animation of part one will get a reset, when part two is run.

Here is my script:

Code: php
  1. ;Two cols and two rows are defined.
  2. SETUPGRID
  3. 2
  4. 2
  5. ;Animation of the upper right part.
  6. IF
  7. PERCENT
  8. 50
  9. &lt;=
  10. {
  11. ;Rectangle 3 is choosen (upper right).
  12. MATHS
  13. CurrentRect
  14. ASSIGN
  15. 3
  16. MATHS
  17. GLOBAL1
  18. ASSIGN
  19. percentleft
  20. MATHS
  21. GLOBAL1
  22. MULTIPLY
  23. HALFPI
  24. MATHS
  25. GLOBAL1
  26. DIVIDE
  27. -70
  28. ROTATEXZ
  29. GLOBAL1
  30. 2
  31. }
  32. ;The animation of the lower half of a window.
  33. IF
  34. PERCENT
  35. 50
  36. &gt;=
  37. {
  38. ;The lower left rectangle is choosen.
  39. MATHS
  40. CurrentRect
  41. ASSIGN
  42. 0
  43. MATHS
  44. GLOBAL1
  45. ASSIGN
  46. percentleft
  47. MATHS
  48. GLOBAL1
  49. MULTIPLY
  50. HALFPI
  51. MATHS
  52. GLOBAL1
  53. DIVIDE
  54. 70
  55. ROTATEYZ
  56. GLOBAL1
  57. 5
  58. ;The lower right rectangle is choosen.
  59. MATHS
  60. CurrentRect
  61. ASSIGN
  62. 1
  63. ROTATEYZ
  64. GLOBAL1
  65. 5
  66. }

Reply #5 Top

Quoting Asound, reply 4
When I dont use brackets in the second part, the animation just plays along with the first animation again. While I just define with the first if-statement in front of the first part, how much time I got for this animation.

But if the second part is also in brackets and should only play after 50 percent, the animation of part one will get a reset, when part two is run.

End of Asound's quote

Remember you need to add an END line inside the first If bracketed section or it will continue execution after it.

On the second issue, the setupgrid call will reset all the positions of the rectangles to their defaults.

It looks like you are doing something with rectangle 3 for the first 50% and then rectangle 0 for the last 50%, so you should probably set the position of rectangle 3 at the start of the code that would run when it is > 50% 

You know the ending position as percent would have been 50 so it should be easy to set the position.

As an alternative you could simply call the setup grid only once when say global7 is 0.

so

IF
GLOBAL7
0
=
{

SETUPGRID
2
2

MATHS
GLOBAL7
ASSIGN
1

}

Reply #6 Top

I've got a felling that my plan is not possible. X|

Calling the setupgrid only once is also not possible? May a global variable does contain nothing at first, even not the number/value 0? While using your sample code, it wont work at all xD

 

And since the whole animations, does not have that much time. It also not looks that nice, to have it split up into more than one part. It shurely does not look near as smooth as I intended it.

 

But thanks for your help! I may will come up now with something easier first xD