local assets = vci.assets local count = 0 local timecount=0 --共通変数による同期管理部分 if vci.state.Get("COUNT") then count = vci.state.Get("COUNT") end --全体の切り替え枚数 今回は4X4 local TOTAL = 16 --縦と横の分割数 4 function SetTextureOffset( count ) local offset = Vector2.zero -- y shift local Yshift = math.floor(count / 4) offset.y = -(1/4) * Yshift -- x shift local Xshift = count % 4 offset.x = (1/4) * Xshift assets.material._ALL_SetTextureOffsetFromIndex(0, offset) end SetTextureOffset(count) function update() timecount=timecount+1 --何フレームごとに画像を切り替えるか if timecount>3 then anim() timecount=0 end end --自作関数 function anim() if count >= TOTAL then count = 0 else count = count + 1 end vci.state.Set("COUNT", count) SetTextureOffset(count) end