@RonJeffries Heres an example using the above function. One thing I saw when using it was anytime a zLevel used a negative value, the background of the current sprite would show over the next sprite. I was able to solve that problem by putting the desired zLevel in a table with the image and sorting on zLevel so the images were drawn from low to high.
viewer.mode=FULLSCREEN
function setup()
fill(255)
tab={
{img=asset.builtin.Space_Art.UFO,lev=10},
{img=asset.builtin.SpaceCute.Health_Heart,lev=-3},
{img=asset.builtin.Space_Art.Asteroid_Large,lev=7},
{img=asset.builtin.Space_Art.Red_Ship,lev=4},
{img=asset.builtin.Planet_Cute.Character_Horn_Girl,lev=-5},
}
sort(tab)
end
function draw()
background(92, 89, 32)
currZlevel=0
for z=1,#tab do
setZlevel(tab[z].lev)
text(currZlevel,WIDTH/6+100*z,HEIGHT/2+150)
sprite(tab[z].img,WIDTH/6+100*z,HEIGHT/2,200)
end
end
function setZlevel(z)
zLevel(z-currZlevel)
currZlevel=z
end
function sort(tbl)
table.sort(tbl,
function(a,b)
if a.lev<b.lev then
return true
end
return false
end)
end