Difference between revisions of "SetAnimSize (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
m (Text replacement - "wikitable" to "ts")
m
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
 
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By
 
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By
 
|-
 
|-
| setAnimSize("ani", n) || Definition || AFRLme
+
| setAnimSize("anim", val, duration, easing) || Definition || AFRLme
 
|}
 
|}
  
This small function allows you to quickly set the size(%) of an active animation.
+
This small function allows you to quickly set the size (percent) immediately of an active animation; or over x time with optional easing.
 +
 
  
 
== Instructions ==
 
== Instructions ==
 
1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/>
 
1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/>
2. To use this function you should create an ''execute a script'' action containing...
+
2a. Usage Example #1: update animation size immediately from current size to 10%
<syntaxhighlight>
+
<syntaxhighlight lang="lua">
setAnimSize("animation_name", 200) -- set active animation animation_name's size to 200%
+
setAnimSize("animation_name", 10)
 +
</syntaxhighlight>
 +
2b. Usage Example #2: update animation size over 2000ms from current size to 10% with easeQuintIn easing.
 +
<syntaxhighlight lang="lua">
 +
setAnimSize("animation_name", 10, 2000, easeQuintIn)
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
  
 
== Main Script ==
 
== Main Script ==
<syntaxhighlight>
+
<syntaxhighlight lang="lua">
function setAnimSize(ani, n)
+
function setAnimSize(anim, val, duration, easing)
  getObject("ActiveAnimations[" .. ani .. "]"):setValue(VAnimationSize, n)
+
  duration = duration or 0 -- fallback in case duration equals nil
 +
easing = easing or easeLinearInOut -- fallback in case easing equals nil
 +
-- + --
 +
ActiveAnimations[anim]:to(duration, {Size = val}, easing) -- update animation size
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
  
 
== Syntax Breakdown ==
 
== Syntax Breakdown ==
Line 27: Line 37:
 
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:80%" | Description
 
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:80%" | Description
 
|-
 
|-
| ani || "string" || This should be a "string" value containing the name of the animation you want to affect.
+
| anim || "string" || This should be a "string" value containing the name of the animation you want to affect.
 
|-
 
|-
| n || integer || This should be an integer (number) value which will determine size(%) of the linked animation (ani).
+
| val || integer || This should be a number value which will used to determine size (percentage) of the linked animation (anim).
|}
+
|-
 +
| duration || integer || This should contain a number value in milliseconds of how long you want the animation size to take to change from the current value to the target value.
 +
|-
 +
| easing || integer || This should contain a number value, or the variable name of the easing type that you want to use. Here is a list of available [https://www.visionaire-studio.com/luadocs/lua.html#easing easing options].
 +
|}{{toc}}

Latest revision as of 18:47, 23 August 2022

Name Type By
setAnimSize("anim", val, duration, easing) Definition AFRLme

This small function allows you to quickly set the size (percent) immediately of an active animation; or over x time with optional easing.


Instructions

1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2a. Usage Example #1: update animation size immediately from current size to 10%

setAnimSize("animation_name", 10)

2b. Usage Example #2: update animation size over 2000ms from current size to 10% with easeQuintIn easing.

setAnimSize("animation_name", 10, 2000, easeQuintIn)


Main Script

function setAnimSize(anim, val, duration, easing)
 duration = duration or 0 -- fallback in case duration equals nil
 easing = easing or easeLinearInOut -- fallback in case easing equals nil
 -- + --
 ActiveAnimations[anim]:to(duration, {Size = val}, easing) -- update animation size
end


Syntax Breakdown

Name Type Description
anim "string" This should be a "string" value containing the name of the animation you want to affect.
val integer This should be a number value which will used to determine size (percentage) of the linked animation (anim).
duration integer This should contain a number value in milliseconds of how long you want the animation size to take to change from the current value to the target value.
easing integer This should contain a number value, or the variable name of the easing type that you want to use. Here is a list of available easing options.