@pac - obj files can hold color but it has to be incorporated in the file with the right format. It is not used very often. When applied it just colours the vertices, so you can add colour gradients or solid coloured triangles.
Most users tend to use textures as that gives you a much better 3D effect. They are incorporated in the obj file as a series of points which relate to a specific texture and vertex. You need to read up on this - chase up the 3D epub from ignatz on his website - you might find it in the Codea wiki.
Oh, when using textures you also need a materials file which incorporates lighting properties and texture file details.
@pac Here’s an example showing all the sprites in Blocks.
function setup()
al=assetList("Blocks",SPRITES)
for a,b in pairs(al) do
print(a,b)
end
fill(255)
end
function draw()
background(40, 40, 50)
x,y=1,1
for a,b in pairs(al) do
sprite("Blocks:"..b,x*65,y*65,50)
x=x+1
if x>10 then
y=y+1
x=1
end
end
text("Blocks",WIDTH/2,HEIGHT-50)
text("use landscape orientation",WIDTH/2,HEIGHT-100)
end
@pac This doesn’t pass a table to tween, but it uses one in tween. I’m using the Asset list from the above code.
displayMode(FULLSCREEN)
function setup()
al=assetList("Blocks",SPRITES)
sp={x=0,y=HEIGHT/2,a=1}
tween(5,sp,{x=WIDTH,y=HEIGHT/2,a=#al},
{easing=tween.easing.linear,loop=tween.loop.once})
end
function draw()
background(40, 40, 50)
sprite("Blocks:"..al[sp.a//1],sp.x,sp.y,50)
end
displayMode(FULLSCREEN)
function setup()
str=""
al=assetList("Blocks",SPRITES)
sp={x=0,y=HEIGHT/2,a=1}
tween(5,sp,{x=WIDTH,y=HEIGHT/2,a=#al},
{easing=tween.easing.linear,loop=tween.loop.once},done)
fill(255)
end
function draw()
background(0)
sprite("Blocks:"..al[sp.a//1],sp.x,sp.y,50)
text(str,WIDTH/2,HEIGHT/2)
end
function done()
str="DONE"
end
You can use tween.hasExpired() function (not documented)
displayMode(FULLSCREEN)
function setup()
al=assetList("Blocks",SPRITES)
sp={x=0,y=HEIGHT/2,a=1}
id=tween(5,sp,{x=WIDTH,y=HEIGHT/2,a=#al},
{easing=tween.easing.linear,loop=tween.loop.once})
fill(255)
end
function draw()
background(0)
sprite("Blocks:"..al[sp.a//1],sp.x,sp.y,50)
if tween.hasExpired(id) then
text("Done",WIDTH/2,HEIGHT/2)
end
end