Updated Animation (markdown)
35
Animation.md
35
Animation.md
@@ -1,62 +1,53 @@
|
|||||||
With animations you can create a beautiful experience for users while interacting with objects.<br>
|
With animations you can create a beautiful experience for users while interacting with objects.<br>
|
||||||
For now the animation class is very basic, i will expand it in the future, but i have to say already now you can do almost everything you can imagine!
|
For now the animation class is very basic, i will expand it in the future, but i have to say already now you can do almost everything you can imagine!
|
||||||
|
|
||||||
Right now animation is a class which makes use of the timer event
|
Right now animation is a class which makes use of the timer event<br>
|
||||||
|
|
||||||
Here is a example of how to create a default animations:
|
|
||||||
````lua
|
|
||||||
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
|
|
||||||
local aAnimation = mainFrame:addAnimation("anim1")
|
|
||||||
````
|
|
||||||
|
|
||||||
This will create a default animation without anything in it
|
|
||||||
|
|
||||||
Here are all possible functions available for animations:
|
Here are all possible functions available for animations:
|
||||||
|
|
||||||
## add
|
## add
|
||||||
adds a new function to your animation
|
adds a new function to your animation
|
||||||
````lua
|
````lua
|
||||||
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
local testButton = mainFrame:addButton("myTestButton"):show()
|
local testButton = mainFrame:addButton("myTestButton"):show()
|
||||||
local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setPosition(3,3) end):wait(1):add(function() testButton:setPosition(1,1,"r") end):wait(2):add(function() testButton:setPosition(1,1,"r") end)
|
local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setPosition(3,3) end):wait(1):add(function() testButton:setPosition(1,1,"r") end):wait(2):add(function() testButton:setPosition(1,1,"r") end)
|
||||||
|
|
||||||
aAnimation:play() -- this will set the button position to 3,3, waits 1 sec., sets it to 4,4, waits 2 sec. and then sets the position to 5,5
|
aAnimation:play() -- this will set the button position to 3,3, waits 1 sec., sets it to 4,4, waits 2 sec. and then sets the position to 5,5
|
||||||
````
|
````
|
||||||
**args:** function<br>
|
**parameters:** function<br>
|
||||||
**returns:** animation object<br>
|
**returns:** self<br>
|
||||||
|
|
||||||
## wait
|
## wait
|
||||||
sets a wait timer for the next function after the previous function got executed, no wait timer calls the next function immediatly
|
sets a wait timer for the next function after the previous function got executed, no wait timer calls the next function immediatly
|
||||||
````lua
|
````lua
|
||||||
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
local testButton = mainFrame:addButton("myTestButton"):show()
|
local testButton = mainFrame:addButton("myTestButton"):show()
|
||||||
local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setPosition(3,3) end):wait(1):add(function() testButton:setPosition(1,1,"r") end):wait(2):add(function() testButton:setPosition(1,1,"r") end)
|
local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setPosition(3,3) end):wait(1):add(function() testButton:setPosition(1,1,"r") end):wait(2):add(function() testButton:setPosition(1,1,"r") end)
|
||||||
|
|
||||||
aAnimation:play() -- this will set the button position to 3,3, waits 1 sec., sets it to 4,4, waits 2 sec. and then sets the position to 5,5
|
aAnimation:play() -- this will set the button position to 3,3, waits 1 sec., sets it to 4,4, waits 2 sec. and then sets the position to 5,5
|
||||||
````
|
````
|
||||||
**args:** timer - how long we should wait to call the next function<br>
|
**parameters:** timer - how long we should wait to call the next function<br>
|
||||||
**returns:** animation object<br>
|
**returns:** self<br>
|
||||||
|
|
||||||
## play
|
## play
|
||||||
starts to play the animation
|
starts to play the animation
|
||||||
````lua
|
````lua
|
||||||
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
local testButton = mainFrame:addButton("myTestButton"):show()
|
local testButton = mainFrame:addButton("myTestButton"):show()
|
||||||
local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setBackground(colors.black) end):wait(1):add(function() testButton:setBackground(colors.gray) end):wait(1):add(function() testButton:setBackground(colors.lightGray) end)
|
local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setBackground(colors.black) end):wait(1):add(function() testButton:setBackground(colors.gray) end):wait(1):add(function() testButton:setBackground(colors.lightGray) end)
|
||||||
|
|
||||||
aAnimation:play() -- changes the background color of that button from black to gray and then to lightGray
|
aAnimation:play() -- changes the background color of that button from black to gray and then to lightGray
|
||||||
````
|
````
|
||||||
**args:** [endlessloop] - bool if it should loop forever - will change that to loopcount in the future<br>
|
**parameters:** [endlessloop] - bool if it should loop forever - will change that to loopcount in the future<br>
|
||||||
**returns:** animation object<br>
|
**returns:** self<br>
|
||||||
|
|
||||||
## cancel
|
## cancel
|
||||||
cancels the animation
|
cancels the animation
|
||||||
````lua
|
````lua
|
||||||
local mainFrame = NyoUI.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
local testButton = mainFrame:addButton("myTestButton"):show()
|
local testButton = mainFrame:addButton("myTestButton"):show()
|
||||||
local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setBackground(colors.black) end):wait(1):add(function() aAnimation:cancel() end):wait(1):add(function() testButton:setBackground(colors.lightGray) end)
|
local aAnimation = mainFrame:addAnimation("anim1"):add(function() testButton:setBackground(colors.black) end):wait(1):add(function() aAnimation:cancel() end):wait(1):add(function() testButton:setBackground(colors.lightGray) end)
|
||||||
|
|
||||||
aAnimation:play()
|
aAnimation:play()
|
||||||
````
|
````
|
||||||
**args:** -<br>
|
**parameters:** -<br>
|
||||||
**returns:** animation object<br>
|
**returns:** self<br>
|
||||||
Reference in New Issue
Block a user