Templates - ADA-Funni/PsychEngine-Lua-Classes GitHub Wiki

Adding a background sprite

require('mods.' .. currentModDirectory .. '.lua.globals')
require('mods.' .. currentModDirectory .. '.lua.object-oriented-programming.object_oriented_programming')

local sprite = YourObject

function onCreate()
    sprite = YourObject.new("bg", "bad", 0, 0, 0.9, 0.9)
    sprite:add(false)
    sprite:screenCenter('xy')
    sprite:accessProperty('alpha', 0.6, false)
end

Adding an animated background sprite

require('mods.' .. currentModDirectory .. '.lua.globals')
require('mods.' .. currentModDirectory .. '.lua.object-oriented-programming.object_oriented_programming')

local sprite = YourObject

function onCreate()
    sprite = YourObject.newAnimated("bg", "bad", 0, 0, 0.9, 0.9)
    sprite:add(false)
    sprite:screenCenter('xy')
    sprite:accessProperty('alpha', 0.6, false)

    -- Adding the animations
    sprite:addAnimationByPrefix('animName', 'animPrefix', 24, true)
    sprite:addAnimationByIndices('animName2', 'animPrefix', {0,1,2,3,4,5,6,7,8,9}, 24, true)

    -- Playing the animations
    sprite:playAnim('animName', true, false, 0)
end