Snippets
Tween + Curves
-- Move particle system on a curve and rotate
startCallbackTween(30000, function(x)
local pos = game.CurrentScene.Curves[3]:curveAt(x)
local direction = game.CurrentScene.Curves[3]:curveDirection(x) - 1.57
local p = graphics.getParticles(game.CurrentScene.Objects.moving)
p.emissionDirection = {0.0, direction, 0.0, direction}
p.center = {pos.x,pos.y}
end, easeLinearIn, true, false)
Text Scroll Pane
textPane = graphics.createTextScrollPane()
textPane.padding = 30
textPane.rect = {x=300,y=100,width=1000,height=700}
textPane.bg = "vispath:bg.png"
textPane.bg9R = {x=55,y=53,width=55,height=53}
textPane.scroll = "vispath:scroll.png"
textPane.scrollHover = "vispath:scroll_h.png"
textPane.scroll9R = {x=0,y=9,width=0,height=9}
textPane.scrollUp = "vispath:up.png"
textPane.scrollDown = "vispath:down.png"
textPane.scrollUpHover = "vispath:up_h.png"
textPane.scrollDownHover = "vispath:down_h.png"
textPane.button = Buttons.textpos
textPane.alwaysShowScrollbar = true
textPane:addText(getObject("(8,0)").Link, Fonts[1], 0xffffff, 0, 0, "")
textPane:addText(getObject("(8,0)").Link, Fonts[2], 0xffff00, 40, 10, "bullet:cursor.png")
textPane:addText(getObject("(8,0)").Link, Fonts[3], 0xff0000, 80, 10, "vispath:bullet.png", {x=-5,y=5})
textPane:addText(getObject("(8,1)").Link, Fonts[3], 0x0000ff, 80, 10, "vispath:bullet.png", {x=-5,y=5})
textPane:addText(getObject("(8,0)").Link, Fonts[3], 0x00ff00, 80, 10, "vispath:bullet.png", {x=-5,y=5})
textPane:addText(getObject("(8,0)").Link, Fonts[1], 0x0000ff, 0, 10, "")
textPane:show()
textPane.scrollPosition = textPane.scrollPosition + textPane.lineHeight * 3 -- manual scrolling, will clamp automatically
--textPane2:destroy() -- to hide
Finished Scripts
Shadertoolkit
shaderBrightness(0.0, 1.0)
shaderBrightness()
Rotate Animation
-- Examples:
setRotateAnimation(Objects["tree1"], 1.0, 0.3, 0.2, 3, graphics.noise)
setRotateAnimation(Objects["tree2"], 1.0, 0.0, 0.2, 3, math.sin)
setRotateAnimation(Objects["tree3"], 1.0, 0.0, 0.2, 3, function(a)return math.sin(graphics.noise(a)) end)
setRotateAnimation(object, speed, offset, strength, direction, func)
-- func can be: function(a)return math.sin(graphics.noise( a )) end
setRotateAnimationToStrength(objectnamestring, speed, offset, strengthFrom, strengthTo, direction, function, time) -> smooth Rotation From - To Strength
-- direction/pinned side:
-- 1 - down, 2 - up, 3 - left, 4 - right
This script allow simple animations that look a tree moving with wind, but can also be used for other things.
setRotateAnimation(object, speed, offset, strength, direction, func)
This can used to apply it to an object.
setRotateAnimationForLua(object, speed, offset, strength, direction, func)
This is used for lua sprites.
setRotateAnimationToStrength(objectnamestring, speed, offset, strengthFrom, strengthTo, direction, function, time)
Animates the strength of an effect.
Curlwrapper
downloadMemory("http://url...", function(s,code,param)
sprite = graphics.loadMemoryJPG(s)
end)
downloadMemory("http://url...", function(s,code,param)
print(s)
end)
downloadFile("http://url...", localAppDir.."/file.txt", function()
print("done")
end)
Allows simple downloading of images or text files. Don't download big files with this.
downloadFile(httpurl, file, onFinish, onProgress)
Saves to a file.
downloadMemory(httpurl, onFinish, onProgress)
Will return the result to onFinish.
In-Scene-Videos
addMovie(Objects["Object0"],"vispath:test.mp4")
addMovie(Objects["Object0"],"vispath:test.mp4",false,1)
addMovieScaled(Objects["Objekt0"],"vispath:test.mp4",2,2,false,1)
Allows showing videos for scene objects.