Has anyone actually tested the 'scroll object texture' command for this? Cause I don't see how it could possibly work. There's no way for you to set what frame you want, from the frame your on since all the command does is shift the UV's at the speed of whatever you set it to. Also you'd have to combine it with 'scale object texture' since scrolling would scroll the entire image, when all you want is a single frame. All this is just to messy.
Here's another example of using the snippet I posted:
global _oldTick as dword
global _newTick as dword : _newTick = timer()
global _delta as float
global _frameTick as float
sync on : sync rate 0
color as dword
subImageWidth = 256
subImageHeight = 256
subImageCountU = 4 // keep to powers
subImageCountV = 4
subImageSubWidth = (subImageWidth/subImageCountU)
subImageSubHeight = (subImageHeight/subImageCountV)
// create subdivided image
for v = 0 to subImageCountV-1
for u = 0 to subImageCountU-1
x1 = u * subImageSubWidth
x2 = x1 + subImageSubWidth
y1 = v * subImageSubHeight
y2 = y1 + subImageSubHeight
color = rgb(rnd(255),rnd(255),rnd(255))
box x1,y1,x2,y2,color,color,color,color
inc i : center text x1+(subImageSubWidth*.5),y1+(subImageSubHeight*.5),str$(i)
next
next
get image 1,0,0,subImageWidth,subImageHeight,1
// setup billboard
make object plain 1,1,1,0
texture object 1,0,1
set object light 1,0
setObjectSubUV(1,0,0,subImageCountU,subImageCountV)
do
// update timer based movement variables
_oldTick = _newTick
_newTick = timer()
_delta = (_newTick-_oldTick)*0.001
// update UV's at the speed of frametick
inc _frameTick, _delta
if _frameTick >= 0.1
_frameTick = 0.0
inc currentU
if currentU = subImageCountU : currentU = 0 : inc currentV : endif
if currentV = subImageCountV then currentV = 0
setObjectSubUV(1,currentU,currentV,subImageCountU,subImageCountV)
endif
paste image 1,0,0
r# = wrapvalue(object angle y(1)+(60*_delta))
yrotate object 1,r#
sync
loop
`This will re-map a plains UV coordinates to suit a tile sheet
function setObjectSubUV(object,subU,subV,subCountU,subCountV)
`Set UV coordinates to suit sprite grid
tx#=subU : ty#=subV : tw#=subCountU : th#=subCountV
xa#=tx#/tw#
ya#=ty#/th#
w#=1.0/tw#
h#=1.0/th#
xb#=xa#+w#
yb#=ya#+h#
lock vertexdata for limb object,0,2
for v=0 to 5
if v=1 or v=3 or v=4 then uvx#=xb# else uvx#=xa#
if v=0 or v=1 or v=3 then uvy#=ya# else uvy#=yb#
set vertexdata uv v,uvx#,uvy#
next v
unlock vertexdata
endfunction